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:
extract({ :foo => 'bar', :foo2 => 'bar2' })
puts foo # 'bar'
puts foo2 # 'bar2'
Note that the keys are private, and that the scope needs to stay local.
You can get close:
Or I suppose we could extend Hash to extract into instance variables: