From: Navindra Umanee Date: 2005-07-16T17:23:52+09:00 Subject: delaying string evaluation Hi, I would like to partially expand a string and then further expand it later on when more information is available. I am currently using string interpolation with a reeval method suggested by Bill Kelly. class String def reeval(b = TOPLEVEL_BINDING) eval("< "one #{delayed}" s = s.reeval(binding) # => "one two" As a more complex example, this is a string I wish to partially expand: options = [ 10, 20, 30, 40, 50 ] combobox =<<"END" ... #{options.map {|n| %{} }.join("\n") } ... END The idea is to create the combobox and then later insert the SELECTED part, when I know the value of thread_threshold. Unfortunately, the above partial expansion is: This would have been great, except that I have all these values for 'n' that have been left out of the expressions that I want to evaluate afterwards. That is, I want the partial expansion to be this: and later when I reeval the string: thread_threshold = 50 combobox.reeval(binding) the result should be: Anyone have any ideas for how I can get a correct partial expansion? I have a lambda/closure feeling about how this should work, but I can't quite see the solution in the context of strings. Thanks, Navin.