From: dblack@... Date: 2007-07-23T06:11:11+09:00 Subject: Re: Syntax bug, in 1.8.5? return not (some expr) <-- syntax error vs return (not (some expr)) <-- fine Hi -- On Mon, 23 Jul 2007, Good Night Moon wrote: > On Sun, 22 Jul 2007 16:51:26 +0900, Sharon Phillips wrote: >> There's a difference between [not, and, or] and [!, &&, ||] Not sure >> what it is, but I've found it better to use the latter. Still, if you >> wrap the whole statement in another set of brackets (like >> intersects_good) it will work. >> >> def intersects_bad(other) >> return (not ((other.x1 < self.x0 or self.x1 < other.x0) and >> (other.y1 < self.y0 or self.y1 < other.y0))) >> end >> >> 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 -- * Books: RAILS ROUTING (new! http://www.awprofessional.com/title/0321509242) RUBY FOR RAILS (http://www.manning.com/black) * Ruby/Rails training & consulting: Ruby Power and Light, LLC (http://www.rubypal.com)