Ruby - Hashes
Identify the error in this Ruby code:
h = {a: 1, b: 2}
h.each do |k|
puts k
endh = {a: 1, b: 2}
h.each do |k|
puts k
endeach on a hash yields key and value, but with only one block parameter |k|, Ruby assigns an array [key, value] to k. No error occurs.[:a, 1] and [:b, 2].15+ quiz questions · All difficulty levels · Free
Free Signup - Practice All Questions