You can iterate through all values of an hash using each_value
; or, you can iterate trough all key/value pairs of an hash using each
, which will yield two variables, key and value.
If you want to print a single value for each hash value of the outer hash, you should go for something like this:
ary.each_value { |x| puts x[:label] }
Here's a more complex example that shows how each
works:
ary.each { |key, value| puts "the value for :label for #{key} is #{value[:label]}" }