From: Trans Date: 2006-08-12T03:00:05+09:00 Subject: Re: nonce Tom Jordan wrote: > Instead of a singleton class how about using it to denote code that is executed > only the first time it is processed. > > def learn_leason > nounce { touch :hand => :stove_top; puts 'Ouch' } > touch :hand => :cool_water; puts 'Ahhh' > end > > loop { learn_leason } > > Output: > Ouch > Ahhh > Ahhh > Ahhh > ... > > or even like this > > loop { nounce { index = 0 } > do_something_useful > index += 1 > } How might that be implemented? (s/nounce/nonce/ btw) T.