Skip to content

Instantly share code, notes, and snippets.

@rtecco
rtecco / destr.rb
Created November 22, 2011 17:58 — forked from blambeau/destr.rb
Fun destructuring in Ruby 1.9
class Hash
def with(&block)
block.call *block.parameters.map{|x| self[x.last]}
end
end
# Example
h = {:name => "blambeau", :hobby => "ruby"}