Skip to content

Instantly share code, notes, and snippets.

@nekova
Created July 16, 2014 15:09
Show Gist options
  • Save nekova/bdbc625d1cddad498dc4 to your computer and use it in GitHub Desktop.
Save nekova/bdbc625d1cddad498dc4 to your computer and use it in GitHub Desktop.
right = { 'alphabet' => ['r', 'i', 'g', 'h', 't'] }
left = { 'alphabet' => ['l', 'e', 'f', 't'] }
right.merge(left)
#=> {"alphabet"=>["l", "e", "f", "t"]}
#=> be overwritten
right.merge(left){|key, old, new| old + new}
#=> {"alphabet"=>["r", "i", "g", "h", "t", "l", "e", "f", "t"]}
@nekova
Copy link
Author

nekova commented Jul 16, 2014

key = 'alphabet'
new_hash[key] = right[key] + left[key]

Hmm.......

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment