Skip to content

Instantly share code, notes, and snippets.

@13k
Created April 6, 2013 23:57
Show Gist options
  • Select an option

  • Save 13k/5328181 to your computer and use it in GitHub Desktop.

Select an option

Save 13k/5328181 to your computer and use it in GitHub Desktop.
Hash "mapping" returning a new hash, instead of using the ugliest thing: `Hash[ Hash#map ]`
h = {a: 13, b: 31}
# => {:a=>13, :b=>31}
h.merge(h) {|k, v0, v1| v0 * 2 }
# => {:a=>26, :b=>62}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment