title: Ruby: eval with string interpolation
body: <p>I don't understand, why <code>eval</code> works like this:</p>
  
  <pre><code>"123 #{456.to_s} 789" # =&gt; "123 456 789"
  eval('123 #{456.to_s} 789') # =&gt; 123
  </code></pre>
  
  <p>How can I interpolate into a  string inside <code>eval</code>?</p>
  
  <p><strong>Update:</strong></p>
  
  <p>Thank you, friends. It worked. </p>
  
  <p>So if you have a string variable with <code>#{}</code> that you want to eval later, you should do it as explained below: </p>
  
  <pre><code>string = '123 #{456} 789' 
  eval("\"" + string + "\"")
  # =&gt; 123 456 789
  </code></pre>
  
  <p>or </p>
  
  <pre><code>string = '123 #{456} 789' 
  eval('"' + string + '"')
  # =&gt; 123 456 789
  </code></pre>