Реклама

Ruby – Class constants

A constant has a name starting with an uppercase character. It should be assigned a value at most once. In the current implementation of ruby, reassignment of a constant generates a warning but not an error (the non-ANSI version of eval.rb does not report the warning):

Constants may be defined within classes, but unlike instance variables, they are accessible outside the class.

Constants can also be defined in modules.

Advertisement

Leave a Reply