Not exactly. The language looks like Java to me. At least in Java 8, 1 is not equivalent to true and 0 is not false. Even in the tutorials I see geeksforgeeks, they are using an if - else statement for the conversion. Edit: Just realised this is C#. Anyway, same issue here so. Implicit conversion from int to bool is not allowed.
It's C#, and apparently they are using the unity engine which stores bools as 0 or 1 integers, which is why this works. They are only converting that 0 or 1 to false or true, in theory it should never be a 2 or 3, if it is, something is messing up elsewhere.
Doesn't excuse the fact it's still badcode tho lol.
It's really annoying to see code like this (obviously not within the context of r/badcode when the author realises it's bad, but like actual production code). The System namespace has like a million general-purpose exception classes that can be applied to almost every scenario. Why aren't people using them?!?!
View all comments
Show parent comment
1
u/0Flight64 Feb 03 '22 edited Feb 03 '22
Not exactly. The language looks like Java to me. At least in Java 8, 1 is not equivalent to true and 0 is not false. Even in the tutorials I see geeksforgeeks, they are using an if - else statement for the conversion. Edit: Just realised this is C#. Anyway, same issue here so. Implicit conversion from int to bool is not allowed.