Ruby - Hashes
Fix the error in this Ruby code snippet:
h = {a: 1, b: 2}
h.values.each do |k, v|
puts k
endh = {a: 1, b: 2}
h.values.each do |k, v|
puts k
endh.values returns an array of values only, so each yields one element per iteration.|k, v|, but only one value is yielded, causing an error.|v| to match the single yielded value.15+ quiz questions · All difficulty levels · Free
Free Signup - Practice All Questions