Aleksi Niemel<aleksi.niemela / cinnober.com> writes:

> Now I managed to drive myself almost insane. I thought private variables
> could not be changed outside class. Anyway, the source code below does
> change.

You can do this a whole lot easier with instance_eval:

   class Private
     def initialize
       @private = "secret"
     end
     def get
      @private
     end
   end

   priv = Private.new
   puts priv.instance_eval { @private }


Ruby doesn't guarantee that you can't poke around inside an object or
class. In fact, quite the reverse--it provides many mechanisms to let
you do just that.

However, I hadn't realized that you could do the trick with
late-binding instance variables. I wonder what mischief that could be
used for.


Thanks


Dave