I would like to use the value of the first argument in a ternary expression to do something like:
a() ? b(value of a()) : c
Is there any way to do this? a is a function that is expensive to run several times and returns a list. I need to do different calculations if the list is NULL. I want to express this in a three-dimensional expression.
I tried to do something like:
String a()
{
"a"
}
def x
(x=a()) ? println(x) : println("not a")
But this is pretty ugly ...
source
share