[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

Re: #{} and \" don't like each other

Peter

9/16/2003 10:38:00 PM

1 Answer

Hal E. Fulton

9/16/2003 10:49:00 PM

0

Peter wrote:

>>FWIW, this avoids it:
>>
>> name = "peter"
>> print "<user name=\"#{name}\"></user>"
>>
>>So it evidently has to do specifically with the escaped terminator
>>*inside* the interpolated part.
>
>
> I know this avoids it, but it was when the name=\"#{name}\" needed to
> become optional, I moved it all inside the #{} and used the ? : operator
> to either generate the "name=\"" + name + "\"" or else a simple "".

Oh, yes. Of course.

Well, all I can say now is that it only seems to complain when the
escaped terminator is the same terminator that would end the string
that surrounds the interpolated piece.

So if you mix quotes (as in Michael Garriss''s reply) you should be OK.

Hal