From: x1 Date: 2006-08-12T13:14:22+09:00 Subject: Re: Simple question regarding hashes Yep.. Thanks alot. This some pretty neat stuff. :-) hash = { "foo" => Proc.new { x = [] y = [] hash = { "x" => ["a", "b", "c"].each {|i| x << i}, "y" => ["x", "y", "z"].each {|i| y << i} } }.call } puts hash['foo']["y"][1] puts hash['foo']["x"][1] >ruby test1.rb y b >Exit code: 0 On 8/11/06, Pe�a, Botp wrote: > fr x1: > # can you define the value of a hash based on an iteration, or an if > # statement etc.. > > if it's code that you want, then Proc can do anything > > irb(main):003:0> hash = {"foo" =>Proc.new {1+1 == 3 ? "yes" : "no"}} > => {"foo"=>#} > irb(main):005:0> hash["foo"] > => # > irb(main):006:0> hash["foo"].call > => "no" > > is that what you want? > kind regards -botp > >