oakkitten wrote: ↑18 Dec 2018, 16:32
now the only remaining question is, why "(0) foo bar baz 1" evaluates to "01" (and what is the type of this?)
(0) evaluates to 0 which would mean
false in a boolean sense, but it gets concatenated with the
blank variables foo, bar, and baz (the result is still 0 and hence,
false, while 000 is also seen as 0)
It also gets concatenated with the number 1 (which itself means
true, because everything else than 0 and blank means true - that's why the resulting string 01 also means true)
Compare
https://autohotkey.com/docs/Variables.htm#Expressions :
Boolean values: When an expression is required to evaluate to true or false (such as an IF-statement), a blank or zero result is considered false and all other results are considered true. For example, the statement if ItemCount would be false only if ItemCount is blank or 0. Similarly, the expression if not ItemCount would yield the opposite result.
Also
Code: Select all
if (0) foo bar baz "a" ; --> 0a
msgbox, % "this will show: " (0) foo bar baz "a" ; force expression mode with %