In the C programming language, int values double up as boolean values.
I've been told this is bad.
But why is it bad?
At first, I thought of course it's bad, but couldn't think of any examples
illustrating why it's bad.
Could you help me find some examples?
As far type systems in general are concerned.
Likewise char
and float
can both get implicitly converted to int
in C'
Tried in python with static type checking (mypy). That too has no complaints to make:
def incr(num: int) -> int:
return num + True
incr(2)
# 3
Last updated: Jan 29 2023 at 18:03 UTC