Gary Wright
4/20/2007 5:06:00 AM
On Apr 19, 2007, at 11:50 PM, bbiker wrote:
> p (( 3 unless true)) => nil # you're asking for the result
> of '3 unless true', )
if 'x unless y' is a valid expression then why is the *extra* set
of parenthesis needed when that expression is used as a method argument?
foo(x unless y) # syntax error
foo((x unless y)) # not a syntax error
This seems to be a problem with any of the statement modifier forms:
if, rescue, while, until.
Looking at parse.y it seems that the grammar differentiates between
arguments and statements. Adding the parens forces the statement to
become an expression.