From: Roger Pack Date: 2007-07-24T07:22:27+09:00 Subject: Re: Syntax bug, in 1.8.5? return not (some expr) <-- syntax I agree that if not File.exists? "a" do stuff end would be nice intuitively. I wish... unknown wrote: > Hi -- > > On Mon, 23 Jul 2007, Good Night Moon wrote: > >>> >>> by the way, what's the difference between the two methods? They appear >>> identical. >> >> Thanks. The difference is just to point out what looks like >> a bug; the parens shouldn't make a difference. Look at >> my other reply in this thread for elaboration. > > I don't think it's a bug. Have a look at these examples: > > def x; return 1 and puts "I'm gone!"; end > SyntaxError: compile error > (irb):3: void value expression > > def x; 2 not 3; end > SyntaxError: compile error > (irb):5: syntax error, unexpected kNOT, expecting kEND > > These both make sense. 'and' is right-associative, so you're trying > to do something after having already returned, which doesn't work. > And in general you can't do "x not y", which is what "return not ..." > is read as. > > > David -- Posted via http://www.ruby-forum.com/.