From: Eric Hodel Date: 2005-10-28T13:37:57+09:00 Subject: Re: Expression Evaluation Problem On Oct 27, 2005, at 8:27 PM, Shannon Fang wrote: > Hi, > > I have a program which runs ok for a very long time, today I try to > modify it some strange error pops up (before I modify): > > c:/ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:18:in > `require__': ./dbload.rb:110: void value expression (SyntaxError) > return (@acc.class == Hash) and (@auth.class == Hash) and > (@cat.class == Hash) > ^ from > c:/ruby/lib > /ruby/site_ruby/1.8/rubygems/custom_require.rb:18:in `require' > from F:/work/svn/dproc/dproc.rb:5 > > The problematic source codes are as follow: > > dbload: > def loaded? > return (@acc.class == Hash) and (@auth.class == Hash) and > (@cat.class == Hash) > end > > Now I add a () in the loaded? function make it like: > > return ((@acc.class == Hash) and (@auth.class == Hash) and > (@cat.class == Hash)) > > The error disappeared! > > My question is, which operator has higher priority? return or and? return is higher. > I have used this code for a long time, but never had this problem > before... Any change in v1.8 probably? No. $ cat x.rb def which? return 'return is higher' and 'and is higher' end puts which? $ ruby168 -v x.rb ruby 1.6.8 (2002-12-24) [powerpc-darwin8.2.0] x.rb:2: void value expression $ ruby182-orig -v x.rb ruby 1.8.2 (2004-12-25) [powerpc-darwin8.0] x.rb:2: void value expression Maybe you had: $ cat y.rb def which? return 'return is higher' && '&& is higher' end puts which? $ ruby -v y.rb ruby 1.8.3 (2005-09-21) [powerpc-darwin8.2.0] && is higher -- Eric Hodel - drbrain@segment7.net - http://segment7.net FEC2 57F1 D465 EB15 5D6E 7C11 332A 551C 796C 9F04