blanks in ternary operator
Posted: 19 Dec 2017, 10:36
- I used to use illegal ternary operator lines in AHK v1 to achieve 'if a then do b else do nothing'.
(cond) ? (action) ;not allowed in AHK v2
I've been changing these to one of:
(cond) && (action)
(cond) ? (action) : 0
(cond) ? (action) : () ;not allowed in AHK v2
However, it seems that using () is illegal in AHK v2 (but not in AHK v1).
- I can just use 0 every time. But, out of interest, I'm not sure exactly why the lines marked below don't work.
- The reason I might use parentheses, is to indicate that literally nothing would happen (cf. 0 being assigned to something), or, to be able to quickly type something there at a later date.
(cond) ? (action) ;not allowed in AHK v2
I've been changing these to one of:
(cond) && (action)
(cond) ? (action) : 0
(cond) ? (action) : () ;not allowed in AHK v2
However, it seems that using () is illegal in AHK v2 (but not in AHK v1).
- I can just use 0 every time. But, out of interest, I'm not sure exactly why the lines marked below don't work.
- The reason I might use parentheses, is to indicate that literally nothing would happen (cf. 0 being assigned to something), or, to be able to quickly type something there at a later date.
Code: Select all
q::
var := (var = 1) ? 2 : () ;doesn't work
var := (var = 1) ? () : 3 ;doesn't work
var := (var = 1) ? 2 : (,) ;doesn't work
var := (var = 1) ? (,) : 3 ;doesn't work
var := (var = 1) ? 2 : (0,) ;doesn't work
var := (var = 1) ? (0,) : 3 ;doesn't work
var := (var = 1) ? 2 : (,0) ;doesn't work
var := (var = 1) ? (,0) : 3 ;doesn't work
var := (var = 1) ? 2 : ;doesn't work (understandable)
var := (var = 1) ? : 3 ;doesn't work (understandable)
var := (var = 1) ? 2 : (0,0)
var := (var = 1) ? (0,0) : 3
var := (var = 1) ? 2 : ("")
var := (var = 1) ? ("") : 3
var := (var = 1) ? 2 : (0)
var := (var = 1) ? (0) : 3
return