4 ms·
First, it's easy to fix by just using ===. Second, It's more of a blub programmer thing. From multiversal equality's perspective, almost every mainstream stati
by namelosw 6y ago
First, it's easy to fix by just using ===.
Second, It's more of a blub programmer thing. From multiversal equality's perspective, almost every mainstream statically typed language is also a semantic mess - you can even compare int to a boolean with == in a statically typed language without having any type errors, despite the comparisons always return false and 99 out of 100 that's not what people meant.
- deleted 6y ago[deleted]
- willtim 6y agoMost mainstream statically typed languages use subtyping, that is why they permit equality comparisons of different (sub) types. But they should and do obey all the usual mathematical laws, associativity, transitivity etc.
- nyanpasu64 6y agoIn C++, you cannot compare unrelated types unless there's an implicit conversion or explicit equality operator (or something like that). In Rust, you cannot compare same or different types unless you implement PartialEq, and you can't compare an int with a bool. In Java, you can't use == to compare an int and a bool (both primitives).