I would very much appreciate this. I've been doing a chunk of work in Rust lately and it has the philosophy of "everything is an expression". It leads to things like this
def val = if (something) { "hello" } else { "other stuff" } being very normal, which helps with a fair few constructs. Specifically in rust it helps you manage safety blocks, which isn't an issue in Groovy per se, but I can see that mapping over into DSLs pretty well. My humble opinion would be that if you were to do it, then I would much rather it be done "properly", is, having the if/ switch become expression constructs rather than simple statements. David. On 27 September 2017 at 08:25, Jochen Theodorou <blackd...@gmx.org> wrote: > > > Am 27.09.2017 um 05:37 schrieb Daniel Sun: > >> Hi all, >> >> I have been thinking about support some syntax like `def x = if >> (...) >> { ... } else if (...) { ... } else { ... }`, which will be translated to >> `def x = { if (...) { ... } else if (...) { ... } else { ... } }()` >> >> Any thoughts? >> > > I wonder... > > def x = booleanCondition. >> iftrue {1}. >> elseif (anotherCondidition). >> iftrue {2}. >> elseif (yetAnotherCondition). >> iffalse {3} >> > > would something like this be better ? > > bye Jochen > > >