I want to use different comparisons (either >=
or <
) based on some condition. I thought I’d just define a name f
pointing to the corresponding operation, which works with the following code:
if true
f = >=
else
f = <
end
I can then compare using f(x, y)
.
However, I can’t figure out how to shorten this if/else
condition with the ternary operator. The following code does not work:
f = true ? >= : <
This gives an error syntax: ">=" is not a unary operator
, which doesn’t really help me. Is it not possible to do that?