From: "Mikael Høilund" Date: 2008-05-26T04:41:08+09:00 Subject: Re: Ruby math parenthesis wierdness On May 25, 2008, at 20:49, Tom Verbeure wrote: > All, > > The code below: > > m = 5*( > (1.0) This is the cause of the unexpected behavior. From what I can see, Ruby is interpreting the newline after (1.0) as a statement separator. Compare: puts 5*( (1.0); - (1.0/2.0) ) What's actually happening is that the third line (- (1.0/2.0)) is seen as a separate statement, not as a continuation on the second line. The minus sign in the beginning of the line is interpreted as the unary negation operator, not the binary (as in relating to two numbers, not one) subtraction operator. This works, however: puts 5*( (1.0) - (1.0/2.0) ) A quick irb session also illustrates my point: >> 1.0 => 1.0 >> -1.0/2.0 => -0.5 >> >> 1.0 - ?> 1.0/2.0 The fact that the last prompt is "?>", not ">>" is the key point here. Hope this helps Mikael Høilund