From: Sharon Phillips Date: 2007-07-22T16:51:26+09:00 Subject: Re: Syntax bug, in 1.8.5? return not (some expr) <-- syntax error vs return (not (some expr)) <-- fine On 22/07/2007, at 5:35 PM, Good Night Moon wrote: > Well, it's all in the subject, to me it looks like a parsing bug: > > class MyRect > def intersects_good(other) > return (not ((other.x1 < self.x0 or self.x1 < other.x0) and > (other.y1 < self.y0 or self.y1 < other.y0))) > end > > 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 > end > > foo> ruby -c myrect.rb > myrect.rb:8: syntax error, unexpected kNOT, expecting kEND > return not ((other.x1 < self.x0 or self.x1 < other.x0) and > ^ > > Any comment? Is this known? Or just some hair in the Ruby grammar? 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. Cheers, Dave