I would like to be able to specify strings using the ternary operator, ie:
[[item.isEven ? “this is even” : “this is odd”]]
Anyone with any workaround for the ternary assignment operator?
I would like to be able to specify strings using the ternary operator, ie:
[[item.isEven ? “this is even” : “this is odd”]]
Anyone with any workaround for the ternary assignment operator?
I’m not aware of any way, but I don’t see any reason you couldn’t accomplish the same with cases and conditions, other than making things more complicated.
I’m aware this is old but you can do ternary in Axure using the classic AND OR method:
condition == 'value' ? trueValue : falseValue;
can be replaced with:
condition == 'value' && trueValue || falseValue;
What??? That’s a game-changer!
I had no idea a boolean expression could return anything but true or false, but apparently that’s not true in Javascript. I finally found a good explanation of it here.
Thanks!
I actually learnt this method doing Lua years ago because Lua doesn’t have a ternary operator, so it’s not just JavaScript! Just checked, and it works in Python too.
That’s cool, I never knew that. Though now that I think about it, it explains the common pattern of:
function foo(arg){
arg = arg || "some default";
}
I just never put 2 and 2 together.
Where has this been all my life? So useful. E.g., display an m-dash in a repeater if the column value is empty:
[[Item.columnName == "" && "—" || Item.columnName]]
Great new tool for the toolbox.