question

SudheerReddy avatar image
0 Likes"
SudheerReddy asked Joerg Vogel edited

Query on Ternary Operator

In below Image before ? there is no condition. So we don't get true or false as there is no condition before question mark "?" . Then how does still below return statement is working. How is it deciding true or false.

FlexSim 19.2.4
ternary
ternary.jpg (33.0 KiB)
ternnary1.jpg (36.8 KiB)
5 |100000

Up to 12 attachments (including images) can be used with a maximum of 23.8 MiB each and 47.7 MiB total.

1 Answer

Joerg Vogel avatar image
0 Likes"
Joerg Vogel answered Joerg Vogel edited

true: value != 0,or a pointer, not NULL, ...

false value == 0, NULLVAR, NULL, not existing,...

· 2
5 |100000

Up to 12 attachments (including images) can be used with a maximum of 23.8 MiB each and 47.7 MiB total.

Mischa Spelt avatar image Mischa Spelt commented ·

Actually, the first one should be "value != 0" :-)
I.e., false is 0 and everything that is not false is true.

1 Like 1 ·
Joerg Vogel avatar image Joerg Vogel commented ·

and by the way, what is NULL

0 Likes 0 ·