I can create a block that will extract hash elements and turn them into local variables, but I\'m wondering if a native method already exists. Something like this:
You can get close:
bar, bar2 = h.values_at :foo, :foo2
Or I suppose we could extend Hash to extract into instance variables:
class Hash def extract o each { |k, v| o.instance_variable_set '@' + k.to_s, v } end end h.extract self p [@foo, @foo2]