On Tue, May 28, 2013 at 4:31 PM, Tadeusz Bochan <lists / ruby-forum.com>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 `<main>'
> (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