Details
Description
I would love to see Groovy support right-side unless / if expressions like in Python or Ruby as they make the code often more readable.
Here is a small example:
doSomething() unless (x > 10) (...) triggerSomethingNasty() if (x < 10)
Activity
blackdrag blackdrag
made changes -
| Field | Original Value | New Value |
|---|---|---|
| Fix Version/s | 4.0 [ 18928 ] |
what we could have is
unless(x>10){doSomething}which is more or less like an if with a negated condition. The other order is a bit problematic in Groovy because there is no execution style like that in all of groovy. That would mean adding a new idiom, which makes the language more complicated. What could be done, would maybe:
{doSomething}.unless(x>10)which is not exactly like in Python, but I think that is good enough. For this solution a category could be used to see if it is good.