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

D

Donglai Gong

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"
^
 
W

WATANABE Hirofumi

Hi,

Daniel Carrera said:
dcarrera ~ $ ruby -v
ruby 1.8.0 (2002-12-24) [sparc-solaris2.8]
dcarrera ~ $ irb=> "whatever"


What's the problem?

Your ruby is too old.

ChangeLog says:

Tue Apr 8 11:49:31 2003 Yukihiro Matsumoto <[email protected]>

(snip)

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

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,770
Messages
2,569,584
Members
45,075
Latest member
MakersCBDBloodSupport

Latest Threads

Top