- It would seem logical
a ? b, for an if-statement with no else alternative.
- Has there ever been a language that allowed it?
- But since AHK v1 can't actually handle it, ideally it should raise an error before the script begins. (It already does in AHK v2.)
- It seems like the best thing to do would be to explicitly state in the help that *3* arguments must be specified. It's tripped up sufficiently many people.
Code: Select all
q:: ;incomplete ternary operator
MsgBox, % (1 = 1) ? "y" : "n" ;y
MsgBox, % (1 = 1) ? "y" ;(blank) ;silent error
return
[EDIT: @Helgef: Re. the post below.]
[EDIT: Yes a && b is available in AutoHotkey, but has any language ever allowed a ? b.]
[EDIT: A warning in the documentation would be useful: (a) for people using older versions of AHK v1, (b) if an error message is never added to AHK v1.]