From: dblack@... Date: 2006-03-25T03:22:31+09:00 Subject: Re: Bug: Syntax error when using 'or' keyword Hi -- On Sat, 25 Mar 2006, Daniel Harple wrote: > I am getting a parse error when using the 'or' keyword. I do not get this > error with '||'. > > $ ruby -v > ruby 1.8.4 (2005-12-24) [powerpc-darwin8.3.0] > > $ ruby-yarv -v > ruby 2.0.0 (Base: Ruby 1.9.0 2006-02-14) [powerpc-darwin8.5.0] > YARVCore 0.4.0 Rev: 482 (2006-03-08) [opts: ] > > def example(arg) > end > > example(nil || 3) # -> no error > example(nil or 3) # -> parse error, unexpected kOR, expecting ')' There was a thread about this recently on ruby-core. Matz summed up the situation as follows: OK. Keyword logical operators (and, or, not) are far lower precedence than comma, even lower than method calls without argument parentheses (in parser, they are called as commands), so that they are not allowed be a part of argument expression. David -- David A. Black (dblack@wobblini.net) Ruby Power and Light, LLC (http://www.rubypowerandlight.com) "Ruby for Rails" chapters now available from Manning Early Access Program! http://www.manning.com/books/black