From: Kendall Gifford Date: 2013-05-29T07:51:08+09:00 Subject: Re: AAARRRRGH! s="#$" => SyntaxError: compile error --14dae934032bc49d6904ddcf1991 Content-Type: text/plain; charset=UTF-8 On Tue, May 28, 2013 at 4:31 PM, Tadeusz Bochan wrote: > Hi. > I get the following error from the following statement : > s="#$" > > irb(main):001:0> s="#$" > SyntaxError: (irb):1: unterminated string meets end of file > from C:/Ruby200/bin/irb:12:in `
' > (A similar response from 1.8.6 on HPUX.) > > Also, > > irb(main):011:0> s="#$!" > => "" > > Something is broken. Does anyone know whats going on with this ? > This is because when interpolating global variables in a string, you're allowed to omit the curly braces. The following are equivalent: $ irb > $greeting = "Hello" > puts "#$greeting world." Hello world > puts "#{$greeting} world." Hello world So, you're string "#$" makes ruby think you're about to interpolate a global variable. However, you then fail to provide the name of a global. > > s="#"+"$" and s="#\$" work ok, but that does not help when the > string occurs in data which goes into eval. > > Also, this is not good > irb(main):008:0> s=("xxxxxx.....#$yyyyyyyyy") > => "xxxxxx....." > > Is there a fundamental problem with the Ruby parser ? > or is this just an isolated glitch ? > > -- > Posted via http://www.ruby-forum.com/. > > -- Kendall Gifford zettabyte@gmail.com --14dae934032bc49d6904ddcf1991 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable
On Tue, May 28, 2013 at 4:31 PM, Tadeusz Bochan <list= s@ruby-forum.com> wrote:
Hi.
I get the following error from the following statement :
s=3D"#$"

irb(main):001:0> s=3D"#$"
SyntaxError: (irb):1: unterminated string meets end of file
=C2=A0 =C2=A0 =C2=A0 =C2=A0 from C:/Ruby200/bin/irb:12:in `<main>'= ;
(A similar response from 1.8.6 on HPUX.)

Also,

irb(main):011:0> s=3D"#$!"
=3D> ""

Something is broken. Does anyone know whats going on with this ?

This is because when interpolating global variabl= es in a string, you're allowed to omit the curly braces.

The following are equivalent:

$ irb
&g= t; $greeting =3D "Hello"
> puts "#$greeting= world."
Hello world
> puts "#{$gr= eeting} world."
Hello world

So, you're string "#$&quo= t; makes ruby think you're about to interpolate a global variable. Howe= ver, you then fail to provide the name of a global.

=C2=A0

s=3D"#"+"$" and s=3D"#\$" work ok, but that d= oes not help when the
string occurs in data which goes into eval.

Also, this is not good
irb(main):008:0> s=3D("xxxxxx.....#$yyyyyyyyy")
=3D> "xxxxxx....."

Is there a fundamental problem with the Ruby parser ?
or is this just an isolated glitch ?

--
Posted via http://= www.ruby-forum.com/.




--
Kendall G= ifford
zettabyte@gmail.com
--14dae934032bc49d6904ddcf1991--