warning: ambiguous first argument; put parentheses or even spaces

J

John Carter

I'm a little confused by this message...

ruby --version;ruby -we 'A=1;B=2;C=3;D=A -(B-C);p D'
ruby 1.9.0 (2004-07-14) [i686-linux]
-e:1: warning: ambiguous first argument; put parentheses or even spaces
-e:1: undefined method `A' for main:Object (NoMethodError)

ruby1.8 --version;ruby1.8 -we 'A=1;B=2;C=3;D=A -(B-C);p D'
ruby 1.8.1 (2004-02-03) [i386-linux]
-e:1: warning: ambiguous first argument; put parentheses or even spaces
-e:1: undefined method `A' for main:Object (NoMethodError)

It goes away if you make some whitespace tweaks....

ruby1.8 --version;ruby1.8 -we 'A=1;B=2;C=3;D=A-(B-C);p D'
ruby 1.8.1 (2004-02-03) [i386-linux]
2

ruby1.8 --version;ruby1.8 -we 'A=1;B=2;C=3;D=A - (B-C);p D'
ruby 1.8.1 (2004-02-03) [i386-linux]
2

Or decide not to use constants...
ruby1.8 --version;ruby1.8 -we 'a=1;b=2;c=3;d=a -(b-c);p d'
ruby 1.8.1 (2004-02-03) [i386-linux]
2

Even just one...
ruby1.8 --version;ruby1.8 -we 'a=1;B=2;C=3;D=a -(B-C);p D'
ruby 1.8.1 (2004-02-03) [i386-linux]
2



John Carter Phone : (64)(3) 358 6639
Tait Electronics Fax : (64)(3) 359 4632
PO Box 1645 Christchurch Email : (e-mail address removed)
New Zealand

The universe is absolutely plastered with the dashed lines exactly one
space long.
 
Y

Yukihiro Matsumoto

Hi,

In message "warning: ambiguous first argument; put parentheses or even spaces"
|
|I'm a little confused by this message...
|
|ruby --version;ruby -we 'A=1;B=2;C=3;D=A -(B-C);p D'
|ruby 1.9.0 (2004-07-14) [i686-linux]
|-e:1: warning: ambiguous first argument; put parentheses or even spaces
|-e:1: undefined method `A' for main:Object (NoMethodError)

It's sort of difficulties for Ruby parser to tell

D=A -(B-C)

as

D=A(-(B-C))

or

D=A-(B-C)

Be nice, please.

matz.
 

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

Forum statistics

Threads
473,767
Messages
2,569,572
Members
45,046
Latest member
Gavizuho

Latest Threads

Top