From: Guby Date: 2008-03-01T02:31:48+09:00 Subject: Re: String interpolation method? Sweet, that looks better! Good to learn something new! :) S On Feb 29, 2008, at 11:07 AM, Rob Biedenharn wrote: > > If you want it to look even nicer, write it like: > >> a = lambda{|c| "bra#{c}ket"} > >> a[" see "] > => "bra see ket" > > -Rob > > On Feb 29, 2008, at 7:21 AM, Guby wrote: >> Not that it is a lot nicer, but just another solution... and a >> little bit on side of what you wanted, but: >> >> >> a = lambda{|c| "bra#{c}ket"} >> >> a.call(" see ") >> => "bra see ket" >> >> :) >> >> On Feb 28, 2008, at 12:42 AM, John Carter wrote: >> >>> On Thu, 28 Feb 2008, Trans wrote: >>> >>> >>>> => require 'facets/string/interpolate' >>> >>> Hmm.... >>> >>> Very neat in application.... >>> >>>>>> String.interpolate{a} >>> >>> but.... >>> >>> def interpolate(&str) >>> eval "%{#{str.call}}", str.binding >>> end >>> >>> ...equally nasty in implementation. >>> >>> Ah well, clearly then I wasn't missing something.... there is no >>> standard method. >>> >>> Thanks, >>> >>> John Carter Phone : (64)(3) 358 6639 >>> Tait Electronics F > > Rob Biedenharn http://agileconsultingllc.com > Rob@AgileConsultingLLC.com > > >