4 ms·
Maybe. C# uses != and == for string comparisons. Maybe the question should be: should an immutable string class be considered primitive considering how frequent
by jonpaul 16y ago
Maybe. C# uses != and == for string comparisons. Maybe the question should be: should an immutable string class be considered primitive considering how frequently it's used despite the fact it's internally passed by ref? I guess that debate is fairly academic and not very useful. Regardless, I agree with the author's point. I don't like having to use the "equals" method in Java for strings. It feels a bit outdated.
- torme 16y agoAgreed. Thinking about it now, I would rather the inverse in a language be true, and have == be used for value comparison, and have a more wordy function for reference comparison. In my experience, I feel that its a much more common usage, and would probably reduce errors caused by programmers choosing the wrong operator. The only downside to this is that you then have to override an operator if you want to change equality comparison, instead of a function.
- Xuzz 16y agoPython has == for value, and 'is' for reference -- that seems like a good solution to me, since it works for both "primitive" and "complex" data structures.
- Xuzz 16y agoPython has == for value, and 'is' for reference -- that seems like a good solution to me, since it works for both "primitive" and "complex" data structures.