Skip to content

Instantly share code, notes, and snippets.

@ravelll
Created May 24, 2013 03:32
Show Gist options
  • Save ravelll/5641122 to your computer and use it in GitHub Desktop.
Save ravelll/5641122 to your computer and use it in GitHub Desktop.
ruby on rails tutorial Chapter4 exercise4
hsh1 = {first:"Satoshi",last:"Tanaka",age:"25"}
hsh2 = {last:"Suzuki",age:"30"}
#show the newest values
puts hsh1.merge(hsh2)
#show old value when the key duplicated
puts hsh1.merge(hsh2){|key,oldv,newv|oldv}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment