On Aug 13, 2006, at 10:43 PM, Kevin Olbrich wrote: > Anyone know of any ruby shortcuts for multiply assigning elements > in a hash? > > What I need to do is set up a hash like this... > > { "one" => "A", "two"=>"A", "three" => "A" } > > What I would like to do is something like this.... > > { "one","two","three" => "A" } (this doesn't work) > keys = %w(one two three) hash = Hash[ *keys.zip(Array.new(keys.length){"A"}).flatten ] Or maybe in this case the default is good enough? hash = Hash.new { |h,k| h[k] = "A" } hash.values_at("one", "two", "three") p hash > _Kevin > www.sciwerks.com > -- > Posted with http://DevLists.com. Sign up and save your mailbox. >