/ Published in: Ruby
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
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"]]