Raw TRUE/FALSE test on an object Topic is solved

Get help with using AutoHotkey and its commands and hotkeys
jballi
Posts: 525
Joined: 29 Sep 2013, 17:34

Raw TRUE/FALSE test on an object

12 Jan 2019, 23:27

I discovered something unexpected. If you do a raw TRUE/FALSE test on an object or variable that contains an object, the test will return TRUE. For example, "if MyObject", "if {abc:123}", and "if []" will all test as TRUE. This can be useful if a function returns FALSE or an object. And yes, I know you can also do a "if IsObject(xxx)" test to get the same results.

My question: Is this documented anywhere? I've looked but I haven't found anything.
coffee
Posts: 96
Joined: 01 Apr 2017, 07:55

Re: Raw TRUE/FALSE test on an object  Topic is solved

13 Jan 2019, 00:30

jballi wrote:
12 Jan 2019, 23:27
I discovered something unexpected. If you do a raw TRUE/FALSE test on an object or variable that contains an object, the test will return TRUE. For example, "if MyObject", "if {abc:123}", and "if []" will all test as TRUE. This can be useful if a function returns FALSE or an object. And yes, I know you can also do a "if IsObject(xxx)" test to get the same results.

My question: Is this documented anywhere? I've looked but I haven't found anything.
https://autohotkey.com/docs/Objects.htm#Usage_Remarks
Helgef
Posts: 3426
Joined: 17 Jul 2016, 01:02
Contact:

Re: Raw TRUE/FALSE test on an object

13 Jan 2019, 00:34

It is also implied by,
expressions wrote: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
Cheers.
jballi
Posts: 525
Joined: 29 Sep 2013, 17:34

Re: Raw TRUE/FALSE test on an object

13 Jan 2019, 11:10

Thanks guys! I guess I didn't look hard enough.

From the doc:
Objects are always considered true when a boolean value is required, such as in if obj, !obj or obj ? x : y.

Return to “Ask For Help”

Who is online

Users browsing this forum: blue83, Google [Bot], labrint, mike11, Spikea and 170 guests