Have these options been tried?
```
def a = 6
def r = {->
switch (a) {
case 6:
case 8: return 'x'
case 9: return 'y'
default: return 'z'
}
}()
```
or use a local block
```
def a = 6
def r
{
switch (a) {
case 6:
case 8: r ='x'; break
case 9: r = 'y'; break
default: r = 'z'; break
}
}
```
________________________________
From: Milles, Eric (TR Tech, Content & Ops) <[email protected]>
Sent: Monday, November 4, 2019 9:56 AM
To: [email protected] <[email protected]>
Subject: Re: [VOTE] Support switch expression in the next version
By re-writing the AST as a closure expression you are going to add closure
semantics to all the variables referenced within the switch. There are a
number of differences between variables in a block and variables within a
closure.
Is there any idea of how close Java is to finalizing their syntax? The text
block feature underwent a complete overhaul that removed the need for Groovy to
do much of anything.