From: Jeff Peng Date: 2009-12-31T16:13:13+09:00 Subject: Re: Why can't I use "or" here? botp : > On Thu, Dec 31, 2009 at 10:24 AM, Albert Schlef wrote: >> Why? I thought the only diference between "or" and "||" is the >> precedence. > > yes, so you can do eg > >>> system "pwd" or raise "no command here" > /home/botp > => true > >>> system "asdf" or raise "no command here" > RuntimeError: no command here > > if you know perl, this is no surprise.. > I know Perl, but I'm still surprised. # perl -le 'print undef or 4' # perl -le 'print(undef or 4)' 4 # irb irb(main):001:0> puts nil or 4 => 4 irb(main):002:0> puts(nil or 4) SyntaxError: (irb):2: syntax error, unexpected keyword_or, expecting ')' puts(nil or 4) ^ from /usr/bin/irb:12:in `
' And if I "puts (nil or 4)" (there is a blank between them) will print 4. (Just my thought,I was thinking this is a bug.) Regards, Jeff.