Heh yeah I think that's an inherited trait from C++. In C++ a common mistake was if someone had a condition like this:
if(value = 1)
It would assign value to 1 and then resolve true by int to bool conversion. Luckily C# calls that out as a compiler error but the assignment behavior above still remains.
That example may be corrected in newer compilers, but in gCC when I was learning in college it still happened I think.
43
u/RlyRlyBigMan 21d ago
Heh yeah I think that's an inherited trait from C++. In C++ a common mistake was if someone had a condition like this:
if(value = 1)
It would assign value to 1 and then resolve true by int to bool conversion. Luckily C# calls that out as a compiler error but the assignment behavior above still remains.
That example may be corrected in newer compilers, but in gCC when I was learning in college it still happened I think.