2022.07.29 11:22 PM
Sometimes i wonder how the $ differs with ? since most of the times both of them returning the same results. Not sure when to use $ and ?. Help me to understand this guys!
q)$[1b;`true;`false]
`true
q)?[1b;`true;`false]
`true
q)t:([]name:enlist `hi)
q)t
name
----
hi
q)$[(count t)>0;`values;`novalues]
`values
q)?[(count t)>0;`values;`novalues]
`values
2022.07.29 11:47 PM
? can be used in vector-based condition . For example:
?[101b;`a;`b]
`a`b`a
q))
$ is used in single condition :
$[1b;`a;`b]
`a
q))
2022.07.29 11:47 PM
? can be used in vector-based condition . For example:
?[101b;`a;`b]
`a`b`a
q))
$ is used in single condition :
$[1b;`a;`b]
`a
q))
2022.07.30 09:25 PM
Thanks, that helps!
2022.08.03 08:18 AM
Apart from vector-based condition mentioned above, ? Will always run the fail condition unlike $.
$[1;2;’err]
?[1;2;’err]
2022.08.13 02:12 AM
Thanks, I tried both of them and seeing the difference between them
q)$[1;2;'err]
2
q)?[1;2;'err]
'err
[0] ?[1;2;'err]
EMEA
Tel: +44 (0)28 3025 2242
AMERICAS
Tel: +1 (212) 447 6700
APAC
Tel: +61 (0)2 9236 5700
KX. All Rights Reserved.
KX and kdb+ are registered trademarks of KX Systems, Inc., a subsidiary of FD Technologies plc.