title: Interchanging hash keys and local variable names in Ruby
body: <blockquote>
    <p><strong>Possible Duplicate:</strong><br>
    <a href="https://stackoverflow.com/questions/6428433/is-there-a-ruby-equivalent-to-phps-extract">Is there a Ruby equivalent to PHP&#39;s extract?</a>  </p>
  </blockquote>
  
  
  
  <p>Is there any way to take a Ruby hash such as:</p>
  
  <pre><code>myhash = {a: 12, b:24, c:36}
  </code></pre>
  
  <p>and convert this into a set of local variables (short of manually doing the assignments, obviously)?  The result should be just as if I had executed the statements:</p>
  
  <pre><code>a = 12
  b = 24
  c = 36
  </code></pre>
  
  <p>Similarly, can I take a set of defined local variables and make a hash where the keys are the variable names and the values are the variable values (again, short of writing out the hash literally)?  I haven't seen anything like this before so I'm guessing the answer is no, but it would be nice...</p>