Iterating Through Hash Elements : each « Hash « Ruby





Iterating Through Hash Elements

x = { "a" => 1, "b" => 2 }
x.each { |key, value| puts "#{key} equals #{value}" }

 

Related examples in the same category

1.Use each to loop through a hash
2.Assign key and value pair to a string in hash each method
3.Loop hash with interpolation