title: Declaring instance variables iterating over a hash!
body: <p>i want to do the following:</p>
  
  <p>I want to declare the instance variables of a class iterating over a dictionary.</p>
  
  <p>Let's assume that i have this hash</p>
  
  <pre><code>hash = {"key1" =&gt; "value1","key2" =&gt; "value2","key3" =&gt; "value3"}
  </code></pre>
  
  <p>and i want to have each key as instance variable of a class. I want to know if i could declare the variables iterating over that hash. Something like this:</p>
  
  <pre><code>class MyClass
    def initialize()
      hash = {"key1" =&gt; "value1","key2" =&gt; "value2","key3" =&gt; "value3"}
      hash.each do |k,v|
        @k = v
      end
    end
  end
  </code></pre>
  
  <p><strong>I know this doesn't work!</strong> I only put this piece of code to see if you could understand what i want more clearly.</p>
  
  <p>Thanks!</p>