From: dm1 Date: 2005-04-23T21:24:31+09:00 Subject: Re: Clean way to dynamically expand string with "#{expression}"? Taisuke Yamada wrote: > Yes, what I was looking for is 'perfect interpolation on demand' > that'll work whatever content is in interpolated string. I guess > > eval("< > is the best (and robust) solution available as you can choose > random string that probably won't show up in interpolated string. Ah the quest for perfection, we are still not there : irb(main):001:0> str = "blah\nEND_REEVAL\n catch me if you can" => "blah\nEND_REEVAL\n catch me if you can" irb(main):002:0> eval("< > Many interpolation code, including mine and several people > suggested will break if '"' or certain string is contained > in string to interpolate. > > Practically, it doesn't need to be perfect, but it was my > technical interest that there may be better way to do it. > Above code is cleaner and more robust, so I'll go with it. > Thanks for the pointer. > I do share that technical interest. I really wonder if there is a one liner for 'perfect interpolation on demand'. Everything i can think of is a bit longer. Let the quest continue :) Ciao Denis