+ 1
If (-1) {}
What happens if the value of my if-statement becomes -1 ? Is it the same for all languages?
3 Antworten
+ 1
Okay, that should be fine. More generally, any nonzero integer is treated as true.
+ 1
For all the languages I know of, -1 is considered as true. So the if block will be executed.
0
good to know, I wanted to reuse a function that returned -1 in the case of an error 😅