"Eric Hodel" <drbrain / segment7.net> wrote
> > Correct. All instance variables of the object are frozen, not the
> > objects
> > they refer to.
>
> No, the instance variables are not frozen, the instance 'a' of Effable
> is.
>
> #a= modifies a, which is disallowed because a is frozen.
>
> You cannot freeze variables, just objects.
>
> a = "foo"
> a.freeze
> a = "bar"

I respecfully but heartily disagree. Ruby freezes objects by freezing their
instance variables. The latter is the fundamental operation.

a = "foo" # makes the variable a refer to the object "foo"

a.freeze # makes the instance variables of the object "foo" frozen.

Try this:

@a = "foo"
self.freeze
@a = "bar"

Ruby just happens to treat local variables differently. There is no
fundamental reason to do so.