Florian Frank
1/23/2006 1:13:00 PM
On 2006-01-23 21:39:33 +0900, Sky Yin wrote:
> >>begin
> ?> (1 * 2
> ?> + 1)
> ?> end
> => 1
>
> I guess this may be attributed to the Ruby convention that the return
> value by default is from the last line. The weird thing is that even
> parentheses can't guarantee the result to be expected.
"1 * 2" and "+ 1" are both valid ruby expressions, the latter "(unary +)
1". How should Ruby find out, that you wanted to continue your first
expression in the next line?
If you want to avoid this, only break lines after operators, ",", etc.
like
1 * 2 +
1
You can also use
1 * 2 + 1
but I try to avoid this way, I think it's kind of ugly.
--
Florian Frank