Empty Arrays as Falsey

Discuss the future of the AutoHotkey language
iseahound
Posts: 1467
Joined: 13 Aug 2016, 21:04
Contact:

Empty Arrays as Falsey

Post by iseahound » 17 Dec 2022, 12:03

One thing that I noticed is that the for else construction already makes the empty array false.

Code: Select all

for value in []
   ('do something')
else
   Msgbox "empty array"
Perhaps, the if statement should treat it the same.

guest3456
Posts: 3465
Joined: 09 Oct 2013, 10:31

Re: Empty Arrays as Falsey

Post by guest3456 » 17 Dec 2022, 12:36

iseahound wrote:
17 Dec 2022, 12:03
One thing that I noticed is that the for else construction already makes the empty array false.

Perhaps, the if statement should treat it the same.
the for-else is NOT treating the empty array as false

from the docs:

https://www.autohotkey.com/docs/v2/lib/Else.htm
The condition for an Else statement executing depends on the associated statement:

For, Loop (any kind), While: The loop had zero iterations.


Post Reply

Return to “AutoHotkey Development”