Return to Snippet

Revision: 24771
at March 10, 2010 18:47 by inkdeep


Initial Code
foo = {"a" => {"aa" => "b"}, "b" => {"ab" => "c"}, "c" => {"ac" => "d"}} 
#=> {"a"=>{"aa"=>"b"}, "b"=>{"ab"=>"c"}, "c"=>{"ac"=>"d"}}

foo.keys
#=> ["a", "b", "c"]

foo.values(&:keys)
foo.values(&:keys).each(&:values)
foo.values(&:keys).each(&:values).each(&:keys)
foo.values(&:values).each(&:keys)
foo.values(&:values).each(&:values)
#=> [{"aa"=>"b"}, {"ab"=>"c"}, {"ac"=>"d"}]

foo.values(&:keys).collect(&:values)
foo.values(&:values).collect(&:values)
foo.values(&:values).each(&:keys).collect(&:values)
foo.values(&:keys).each(&:keys).collect(&:values)
foo.values(&:keys).each(&:values).collect(&:values)
#=> [["b"], ["c"], ["d"]]

foo.values(&:keys).collect(&:keys)
foo.values(&:values).collect(&:keys)
foo.values(&:values).map(&:keys)
foo.values(&:keys).each(&:values).collect(&:keys)
#=> [["aa"], ["ab"], ["ac"]]

Initial URL

                                

Initial Description

                                

Initial Title
stupid hash experiments in ruby

Initial Tags
ruby

Initial Language
Ruby