From: Eero Saynatkari Date: 2006-01-18T16:51:30+09:00 Subject: Re: Delayed quote expansion On 2006.01.18 14:29, Kevin Olbrich wrote: > I'm sure the answer to this will seem simple once I see it. Right now > it eludes me. > > How can one have a string object like this... > > a = '#{some_value}' > > and have it get evaluated as a double quoted string (with the value for > some_value being automatically replaced) at a later time? > > I would prefer that it is evaluated in context from which it is called. > > I would like to do something like this... > > def func(param) > test = 42 > puts param.quote_substitution > end > > func('my number is #{test}') #=> "my number is 42" You can delay evaluation like this: string = '"#{foo}"' # ... value = eval string # Add a binding if you want > _Kevin E