Ruby - Hashes
What is the output of this Ruby code?
a = {a: 1, b: 2}b = {b: 3, c: 4}c = a.merge(b)
puts c
What is the output of this Ruby code?
a = {a: 1, b: 2}b = {b: 3, c: 4}c = a.merge(b)
puts c
merge behavior with overlapping keysmerge returns a new hash combining keys; overlapping keys get values from the second hash.b (3) replaces value from a (2). Keys :a and :c are included as is.15+ quiz questions · All difficulty levels · Free
Free Signup - Practice All Questions