On Mon, Jul 07, 2003 at 04:32:50AM +0900, Aryeh M. Frierdman wrote:
> foo=1
> test.invariant(foo)
> foo+=1          # should produce an error and exit

Local variables are not objects, and you can't freeze them. They contain a
reference to an object, so you can freeze the object they refer to, but not
the variable itself.

In Ruby, Integers are immutable anyway, so 1.freeze is legal but doesn't
actually do anything.

But if you use instance variables instead:

  @foo = 1
  freeze      # or "self.freeze"
  @foo = 2    # >> TypeError: can't modify frozen object

Regards,

Brian.