why can't I use $3somevar for global variable in ruby 1.8.0?

  • Follow


Hi, I'm new to Ruby programming and I just upgraded from 1.6.8 to 1.8.0 
preview3.  I noticed that I can no longer define global variables like 
$3somevar (an example of the error I get is attached below).  Ruby 1.8 
seems to complain about the 3 following the $ where it was perfectly 
fine with it in 1.6.8.  Is there a reason for this?  Thanks.

Regards,
Donglai

------------------------------------------------------------
%ruby example.rb
example.rb:1: warning: useless use of a variable in void context
example.rb:1: syntax error
$3somevar = "whatever"
                    ^


0
Reply donglai (8) 6/27/2003 3:39:10 AM

Hi,

Daniel Carrera <dcarrera@math.umd.edu> writes:

> dcarrera ~ $ ruby -v
> ruby 1.8.0 (2002-12-24) [sparc-solaris2.8]
> dcarrera ~ $ irb
> >> $3somevar = "whatever" 
> => "whatever"
> 
> 
> What's the problem?

Your ruby is too old.

ChangeLog says:

Tue Apr  8 11:49:31 2003  Yukihiro Matsumoto  <matz@ruby-lang.org>

(snip)

        * parse.y (yylex): disallow global variables like "$1ve".
          [ruby-core:00945]

-- 
eban

0
Reply eban (52) 6/27/2003 4:23:49 AM


1 Replies
71 Views

(page loaded in 0.044 seconds)


Reply: