Parenthetical
Category domino lotusscript
Despite the longwindity of most of my blog posts, when it comes to code, I'm a big fan of brevity (as you may have occasionally noticed). Which is why I'm fond of the ternary operator in JavaScript:
You can, of course, do similar evaluations in Notes Formula:
Despite the longwindity of most of my blog posts, when it comes to code, I'm a big fan of brevity (as you may have occasionally noticed). Which is why I'm fond of the ternary operator in JavaScript:
(OptionEnabled === 'Yes') ? doSomething() : doSomethingElse();
That's just a shortwindy replacement for the following:if (OptionEnabled === 'Yes') {
doSomething();
} else {
doSomethingElse();
}
You can, of course, do similar evaluations in Notes Formula:
isEnabled := @If(OptionEnabled = "Yes"; @True; @False)
...can be abbreviated (admittedly, that's pretty concise to begin with) to:isEnabled := (OptionEnabled = "Yes");
But did you know that even LotusScript supports that kind of brevity? Instead of:If (docConfig.GetItemValue("OptionEnabled")(0) = "Yes") Then
Let isEnabled = True
Else
Let isEnabled = False
End If
Let isEnabled = (docConfig.GetItemValue("OptionEnabled")(0) = "Yes")
Actually, you don't even need the parentheses... the order of operations dictates that the evaluation to the right must complete first in order to complete the leftmost evaluation. But the parentheses make it more readable. Sadly, you can't do this:(docConfig.GetItemValue("OptionEnabled")(0) = "Yes") ? Call doSomething() : Call doSomethingElse()
But it'd be cool if you could.......
Comments