What's the AHK equivalent of one-line logical OR short-circuit evaluation?

134 Views Asked by At

For example, in JavaScript, the following code would log foo:

false || console.log('foo')

How to achieve the same logic in one line in AutoHotkey?

2

There are 2 best solutions below

0
scso On

The same is possible in ahk.

I'm guessing a problem you might be facing is if you tried to use normal commands with it. It's not possible you'd have to be calling functions.

If the thing you want to call is a command you might need to make a custom function to wrap it and be able to use it as function.

(Ahk v2 would be more comfortable to use in this regard but it's still in beta.)

0
bmad On

According to documentation, in v1, both || and && operators short-circuit the evaluation ( just like the OR and AND keywords ).

sources: