From: yermej Date: 2008-02-28T08:50:04+09:00 Subject: Re: String interpolation method? On Feb 27, 4:53 pm, John Carter wrote: > Ok, I'm being stupid probably... > > But I can't spot a method to do string interpolation. > > I have a string... > > a = 'bra#{c}ket' > > The variable c isn't available at the stage of setting that up. Hence > the use of '' instead of "". > > The variable will be available later.... > > At that stage I want to do something like... > > c=' see ' > a.interpolate > > The closest I can get is a bit fugly... > > eval "\"#{a}\"" > => "bra see ket" > > Any better way? > > Thanks, > > John Carter Phone : (64)(3) 358 6639 > Tait Electronics Fax : (64)(3) 359 4632 > PO Box 1645 Christchurch Email : john.car...@tait.co.nz > New Zealand I would do it thusly: a = "bra%sket" c = ' see ' a % c => "bra see ket"