From: Andreas Schwarz Date: 2004-10-30T10:39:01+09:00 Subject: Re: Hashes and Blocks (Syntactical/Feature question) Pete Elmore wrote: > -----BEGIN PGP SIGNED MESSAGE----- > Hash: SHA1 > > I haven't been able to find any documentation on the syntax for a > certain feature, and am not sure the feature exists. What I would like > to do is add a block of code to a hash, so I could do something like this: > > state = 0 > states = { > 0 => { puts "State 0"; state = 1 }, > 1 => { puts "State 1"; state = 0 } > } state = 0 states = { 0 => Proc.new { puts "State 0"; state = 1 }, 1 => Proc.new { puts "State 1"; state = 0 } } while a_condition states[state].call end