Possible to have an if statement in a user-defined function?

{myFunc=(a,b) -> {if: b<>""}b&"."{endif}} fails with unexpected b not known....

1 Like

Hi, and welcome to the forum! :slight_smile:

Absolutely, using the if ternary operator: value if condition else other

For example

{myFunc=(x) -> x & "." if x <> "" else "blank"}

"1" -> {=myFunc("1")}
"" -> {=myFunc("")}

1 Like

Ok thanks Scott, that was entirely useful. Love the software and the quick turnaround on help! I have moved on to nested ternary ifs :slight_smile:

I'm wondering if the output could be an {import} rather than a number/string

Hi Chris, let us continue the discussion in your other thread. I believe you have the same query there.