5 ms·
In practice, how often are you interested in it? C# has `Object.referenceEquals()` because you _may_ want this sometimes. But to have reference equality be the
by __float 4y ago
In practice, how often are you interested in it? C# has `Object.referenceEquals()` because you _may_ want this sometimes. But to have reference equality be the default for something like `==` is a design flaw. Not one that can be fixed now, of course, but it will continue to cause bugs for years to come.
Sometimes, it happens in core Java libraries themselves: https://bugs.openjdk.java.net/browse/JDK-8274779 https://bugs.openjdk.java.net/browse/JDK-8274779
https://github.com/openjdk/jdk/blob/722d639fad2e4fc6eb2aabd427e2719501899cfe/src/java.base/share/classes/sun/net/www/http/HttpClient.java#L310 https://github.com/openjdk/jdk/blob/722d639fad2e4fc6eb2aabd4...
- marginalia_nu 4y agoDunno, I do a fair bit of low level java work, happens every once in a while. Curiously, I don't do a lot of value-comparisons. Based on grepping in the repo for my search engine, I appear to do one every 1000 lines of code. May just be how I write code though. Some people seem to do that a lot more.