Jordan Bedwell is correct. Ruby's constants are /meant/ to be not changed, but 
you can define a constant and change its value later. Ruby will produce a 
warning 'already initialized constant'

Also note that your constant's internal representation can be changed without 
triggering the warning. 

1.9.3p374 :001 > Const = 'a'
 => "a"
1.9.3p374 :002 > Const = 'b'
(irb):2: warning: already initialized constant Const
 => "b"
1.9.3p374 :003 > Const = {a: 'a'}
(irb):3: warning: already initialized constant Const
 => {:a=>"a"}
1.9.3p374 :005 > Const[:a] = 'b'
 => "b"



-- 
Dheeraj Kumar


On Thursday 21 March 2013 at 6:33 AM, Jordon Bedwell wrote:

> On Wed, Mar 20, 2013 at 7:53 PM, Dheeraj Kumar
> <a.dheeraj.ku...@gmail.com (mailto:a.dheeraj.ku...@gmail.com)> wrote:
> > In ruby, any variable whose name starts with a capital letter becomes a
> > constant.
> > 
> 
> 
> Which implies there are actually constants in Ruby.
> 
> -- 
> You received this message because you are subscribed to the Google Groups 
> "Ruby on Rails: Talk" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to rubyonrails-talk+unsubscr...@googlegroups.com 
> (mailto:rubyonrails-talk+unsubscr...@googlegroups.com).
> To post to this group, send email to rubyonrails-talk@googlegroups.com 
> (mailto:rubyonrails-talk@googlegroups.com).
> For more options, visit https://groups.google.com/groups/opt_out.
> 
> 


-- 
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to rubyonrails-talk+unsubscr...@googlegroups.com.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to