Stupid question: What is barring supporting
final r = switch(a) {
case 6: yield 'a'
default: yield 'b'
}
i.e. without any brackets/new operators ? The bracket construct cannot
be a closure, since switch is a keyword, so would it be ambiguous... ?
Related: I have seen Java will have yield, but again: Is that necessary
? To me yield somehow implies that this is a sequence generator
returning one value after another inside a loop...
(we can of course support yield to be Java compatible, but is the
keyword necessary for the syntax to work ? If the case is fallthrough
(*shudder*) then I would still prefer using break (if possible - since
the switch is an expression, break-ing would not work in the
conventional sense anyway)...)
Very much from the uppermost top of my head,
cheers,
mg
On 06/11/2019 21:09, Daniel.Sun wrote:
More concise syntax should be feasible too(statement in parentheses), e.g.
```
def a = 6
def r = (
switch (a) {
case 6: yield 'a'
default: yield 'b'
}
)
assert 'a' == r
```
Cheers,
Daniel.Sun
-----
Apache Groovy committer & PMC member
Blog: http://blog.sunlan.me
Twitter: @daniel_sun
--
Sent from: http://groovy.329449.n5.nabble.com/Groovy-Dev-f372993.html