As I understand from Enums in Ruby question, you use Symbols
to stand for something in ruby instead of enums
in other languages as java or C#.
When you have enums, you can gather related identifiers in one place as below. You can see from the code that there are three colors available, and that paint
method accepts one of those three values.
enum Color {
Red,
Yellow,
Purple
}
public void paint(Color color) {}
how do you document the available values for related symbols in ruby?(:red
, :yellow
, :purple
) Do you have to put it in a comment in the method that uses them, as below?
# allowed colors: :red, :yellow, :purple
def paint(color)
end