I think you could experiment with this using a closure, since return statements have this expression property already:
final foo = ({ -> if(...) { ... } else if(...) { ... } else if(...) { ... } else { ... } }()) From: mg [mailto:mg...@arscreat.com] Sent: Wednesday, March 21, 2018 4:03 PM To: dev@groovy.apache.org Subject: Re: [RFE] Methods as expressions Having control flow statements as expressions in Groovy would feel pretty natural to me. I had always assumed there were reasons why this was not supported, so I did not bring it up... I currently use the simulated eval language extension I proposed for that, i.e. final foo = eval { if(...) { ... } else if(...) { ... } else if(...) { ... } else { ... } } in cases where using "?" would be too complex. That uses a closure, of course, so not optimal for all applications. Question: Does a return-statement inside the if-expression leave the expression, or the enclosing method in Rust ?