title: Setting elements of an array as variables in Ruby
body: <p>Say I have an array holding some variables such as <code>array = ["one", "two", "three"]</code>.
  How would I assign <code>array[0]</code> to be a variable? I know this is probably the wrong way of implementing this, but I'm trying something like this:   </p>
  
  <pre><code>var = 10   
  instance_variable_set("@#{array[0]}", var)
  </code></pre>
  
  <p>I want to be able to call <code>puts @"#{array[0]}"</code> and it give me <code>10</code> as a result.</p>
  
  <p>Edit: I am trying to set the array index (in this case "one") to be a new variable so that I can later call it in other methods. This way <code>set!</code> works for changing the variable later when the array not longer holds the same values. For example, if after setting <code>"one"</code> as a new variable whose value is <code>10</code>, if i get an array containing <code>["three", "two", "one"]</code> I want to be able to call <code>puts array[2]</code> and it give me <code>10</code>.</p>