Thomas Worm wrote:

>a = 5
> b = "#{a}"
> puts b
>
> a = 6
> puts b
>
> Returns:
> 5
> 5
>
> which is clear to me, why. But is there a way to define such a string and
> interpolate it at a later time?

You are asking how to do a "block closure". Study that, because it's a major 
Ruby topic and a very good design technique. I have not yet found a way to 
over-use or abuse blocks in Ruby!

A 'lambda' is one of the block systems that can bond with the variables 
around it. So stick your string evaluator into a lambda, and call it:

>> a = 5
=> 5
>> q = lambda{"#{a}"}
=> #<Proc:0xb721d4d4@(irb):7>
>> q.call
=> "5"
>> a = 6
=> 6
>> q.call
=> "6"

Block closures are a very good design technique because a has a very limited 
scope over a very long lifespan. We could have stored that q and used it 
later. So a becomes very encapsulated.

-- 
  Phlip
  http://www.oreilly.com/catalog/9780596510657/
  "Test Driven Ajax (on Rails)"
  assert_xpath, assert_javascript, & assert_ajax