Q:

access hashes of hashes values in ruby

I have a nested hashes in ruby and I need to access a specific value of it. My hash look like below.
hash = 

    {"list"=>
      {"0"=>
        {"date"=>"11/03/2014",
         "item1"=>"",
         "tiem2"=>"News",
         "item3"=>"",
         "item4"=>"",
         "item5"=>"Videos",
         "Type"=>"Clip"},
       "1"=>
         {"date"=>"11/03/2014",
         "item1"=>"",
         "tiem2"=>"News",
         "item3"=>"",
         "item4"=>"",
         "item5"=>"Videos",
         "Type"=>"Program"}
    }}

I need to access the value of "Type" of each keys. 
I tried with the below code but I am not sure why it didn't work.
hash_type = hash["list"].keys.each {|key| puts key["Type"]}

But it returned the list of keys. i.e 0 and 1
Please help.

A:

hash["list"].map {|_, hash| hash['Type']}

Explanation:
hash = {key: 'value'}

You can loop over a hash using each like this:
hash.each {|pair| puts pair.inspect }    #=> [:key, 'value']

or like this
hash.each {|key, value| puts "#{key}: #{value}"} #=> key: value

Since we don't use key anywhere, some of the IDEs will complain about unused local variable key. To prevent this it is ruby convention to use _ for variable name and all the IDEs will not care for it to be unused.

