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

Discussion in 'Ruby' started by Donglai Gong, Jun 27, 2003.

  1. Donglai Gong

    Donglai Gong Guest

    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"
    ^
     
    Donglai Gong, Jun 27, 2003
    #1
    1. Advertisements

  2. Hi,

    Your ruby is too old.

    ChangeLog says:

    Tue Apr 8 11:49:31 2003 Yukihiro Matsumoto <>

    (snip)

    * parse.y (yylex): disallow global variables like "$1ve".
    [ruby-core:00945]
     
    WATANABE Hirofumi, Jun 27, 2003
    #2
    1. Advertisements

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 (here). After that, you can post your question and our members will help you out.