From: Dave Thomas Date: 2001-07-10T12:43:47+09:00 Subject: [ruby-talk:17592] Re: Constants and Variables "HarryO" writes: > However ... I figured I could then do > > max_size = 10 > max_size.freeze > max_size = 5 # 3 > puts "max = #{max}" # 4 > > and line 3 would produce an error, line 4 would print 10. max_size is a variable that references an object. The variable is not frozen. Fixnums are a bad thing to use, because they have slightly different semantics to other objects. Let's use Strings. a = "hello" ___ __String___ | a | --------->| hello | --- ----------- a.freeze ___ __String___ | a | --------->| hello | (frozen) --- ----------- a[3] = 'f' ### error a = "goodbye" ___ __String___ | a | --------->| goodbye | --- ----------- There's no error: you're not trying to change the frozen object. You're just setting 'a' to reference a different object. Dave