From: Gavin Sinclair Date: 2004-10-30T10:37:21+09:00 Subject: Re: Hashes and Blocks (Syntactical/Feature question) On Saturday, October 30, 2004, 11:29:20 AM, Pete wrote: > 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 } > } It's pretty easy: state = 0 states = { 0 => lambda { puts "State 0"; state = 1 }, ... } while a_condition states[state].call end Cheers, Gavin