Details
-
Type:
Wish
-
Status:
Closed
-
Priority:
Minor
-
Resolution: Won't Fix
-
Affects Version/s: None
-
Fix Version/s: None
-
Component/s: parser
-
Labels:None
-
Environment:all
Description
Parentheses are optional in method calls.
It would be nice if they were also optional in other places such as if, for and while statements ... perhaps even in method declarations.
Issue Links
- is depended upon by
-
GROOVY-762
implement syntax improvements
-
I don't think we can make them optional. Or at least there will be times when we can't.
e.g.
if x > foo {
that could be a call to a closure method foo() passing in the closure as a parameter. Or it could be an if statement.
I guess we could say that the if/while/for syntax takes precedence over the closure calling syntax sugar.
So if you want to do an if then
if x > foo { ... }
to use closure calling syntax
if (x > foo { whatever }) { ... }