From: Gregory Brown Date: 2007-08-07T07:34:40+09:00 Subject: Re: Very weird behaviour of Ruby 1.8.6 with multi-line parenthesis expressions On 8/6/07, Nicolas Lehuen wrote: > Hi, > > I've just lost a few hours on this strange behaviour (bug ?). > Apparently it is caused by some kind of operator precedence > thingamagic. My original code was of course much more complicated, so > finding the problem wasn't easy (I first thought my code was > buggy...). Here is a piece of minimal code that reproduces the > problem : > > 8<-------------8<-------------8<-------------8<------------- > > C:\temp>ver > > Microsoft Windows [version 6.0.6000] > > C:\temp>ruby -v > ruby 1.8.6 (2007-03-13 patchlevel 0) [i386-mswin32] > > C:\temp>type bug.rb > sum1 = 1 + 1 + 1 > > puts sum1 > > sum2 = ( > 1 > + 1 > + 1 + is a unary operator. this parses as: ( 1; +1; +1; ) If you want 3, do: 1 + 1 + 1 which parses as 1 + 1 + 1