Details
-
Improvement
-
Status: Open
-
Major
-
Resolution: Unresolved
-
None
-
None
-
None
-
None
Description
We need unify expression and statement by introduing BlockExpression to support new features. BlockExpression creates a new variable scope and allows yield to produce the final result, thus statement could be used where expression appears, e.g.
GROOVY-9272could leverage the power of this improvement to treat statement as expression.- def v = if (pass) 'Yes' else 'No'
def v = while(cnt < 3) { if (pass) yield 'Yes' // produce the value for BlockExpression (Note: default value is null) cnt++ }
Note: we do not introduce any new syntax for BlockExpression but just introduce a new AST node
Attachments
Issue Links
- Blocked
-
GROOVY-9272 Support switch expression
- Closed