From: Hal Fulton Date: 2004-03-05T06:17:32+09:00 Subject: Re: dynamic assignment of instance variables Mark Hubbart wrote: > On Mar 4, 2004, at 12:04 PM, Hal Fulton wrote: > >> When did this start working? :) This seems to be a good step >> toward singletons for Fixnums (unless those are already working >> also, and I haven't noticed). >> > >> 23.instance_eval {@prime = true} > => true > >> 24.instance_eval {@prime = false} > => false > >> 23.instance_eval {@prime} > => true > >> 24.instance_eval {@prime} > => false > >> RUBY_VERSION > => "1.6.8" > > 1.6.x is the earliest version I've worked with... I remember trying this > when I first started out with ruby :) I thought it was a nifty trick. > You still can't define singleton methods though, just add instance > variables. Though, I suppose you could add a proc object as an instance > variable. The last time I tried this, it was a little deceptive. A variable that you added to one Fixnum was the same for all Fixnums. Hal