In message "Re: [ruby-core:32731] [Ruby 1.9-Bug#3922][Open] Syntax awkwardness"
on Sat, 9 Oct 2010 22:39:10 +0900, Lasse Fabisch redmine@ruby-lang.org writes:
|[code]
|1 + (2; 1) #=> 2
|puts(1; 2) #=> syntax error
|puts((1; 2)) # like: puts 2
|puts (3)*2 #=> 6
|puts(3)*2 #=> nil-error
|puts (1; 2) #=> syntax error
|puts (1; 2)*3 #=> syntax error
|puts ((1; 2))*3 # like: puts 6
|[/code]
|
|IMO this is awkward behavior (but maybe it is intended). I think the same results can be achieved with a newline instead of ';'.
It's intended. Do you have any proposal of 'non-awkward' syntax?
#=> 1
[/code]
But ok, maybe this is needed somewhere (do you have an example? i could
not come up with one yet).
This is what i think should not behave like it does:
[code]
puts (1; 2) # syntax error
[/code]
If im not mistaken the space in front of the parenthesis prevents that
the statement is interpreted as a parenthesized method call, so the (1; 2) should be interpreted as an expression. But then, why does it raise
an error?