From: "Hal E. Fulton" Date: 2001-10-31T17:26:00+09:00 Subject: [ruby-talk:23926] Re: question about string interpolation and '#{}' ----- Original Message ----- From: Phil Tomson Newsgroups: comp.lang.ruby To: ruby-talk ML ; Sent: Wednesday, October 31, 2001 2:16 AM Subject: [ruby-talk:23924] Re: question about string interpolation and '#{}' > In article <005501c161e0$3b6f4100$0300a8c0@austin.rr.com>, > Hal E. Fulton wrote: > >----- Original Message ----- > >From: Phil Tomson > >Newsgroups: comp.lang.ruby > >To: ruby-talk ML ; > >Sent: Wednesday, October 31, 2001 1:36 AM > >Subject: [ruby-talk:23918] question about string interpolation and '#{}' > > > > > >> I think I'm really trying to do some strange things with string > >> interpolation and I'm not sure if what I want to do is completly > >> possible... > > > >Probably a silly question on my part... it's 1:46 am in my timezone -- > >but why are you doing eval str.inspect rather than just eval str? > > > > Good question. Because not all of the stuff in the strings to be eval'ed > is Ruby code, only the stuff between #{ and }. How about something like this: s2 = str.gsub(/"/, '\"') s3 = '"'+s2+'"' eval s3 Hal