Linux Ask!

Linux Ask! is a Q & A web site specific for Linux related questions. Questions are collected, answered and audited by experienced Linux users.

Apr 042013
 

Constant in Ruby

Answer:

In Ruby, a class constant has a name starting with an uppercase character, e.g.

Foo = 'bar'
puts Foo

Where you try to re-define the constant, a warning message will be shown, e.g.

Foo = 'bar'
Foo = '123'

(irb):18: warning: already initialized constant Foo

 Leave a Reply

(required)

(required)

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>