Sphene Community Tools
Community
Copyright © 2007-2018 by
Herbert Poul
Home
Downloads
Documentation
Forums
Users
Issues
You are not logged in.
Login
Register
Change Language:
German
English
French
Polish
Korean
Russian
where to buy dapoxetine in canada
Sandbox
/
Hehe
[
Edit
]
Back to Snip
Warning:
You are editing an old version: By Anonymous at 2015-02-17 15:05:37
Title:
Body:
this regard, symobls could be seen as top level enums. However, the advantage of putting related constants inside a class is that it adds semantics to your application. The constants can appear logically grouped instead of floating in the air on their own. Of course, I'm not saying that these custom enums should replace symobls. I just find it useful to group things that are related together.@Badaud,As you can see in my exemple, I don't create any instance of class Color. I only work with the object Color, which is an instance of class Class. Also, you'll note that i don't write Color.BLUE but Color::BLUE, which triggers the const_missing method. It would be equivalent of doing : Color.const_missing(:BLUE) but there won't be any point to access it that way! Finally, I don't quite understand your claim about type safety. This was a practical example illustrating how to create an enum-like class in ruby. If for some reason Color::BLUE and Chess::KING would be equal then so what? Those are integers values after all. The purpose (in this example at least) was to use an enum as a set of constants logically grouped together. (Like if Color was a namespace)
Tags:
Comma separated list of tags.
Captcha:
Please enter the result of the above calculation.
Change Message:
*
See
WikiDocumentation
on how to format your input.