update is a synonym for merge! : update « Hash « Ruby






update is a synonym for merge!


h = {a:1,b:2}     # Using Ruby 1.9 syntax and omitting braces
h.update(b:4,c:9) {|key,old,new| old }  # h is now {a:1, b:2, c:9}
h.update(b:4,c:9) # h is now {a:1, b:4, c:9}

 

Related examples in the same category