4 ms·
Ok, but then the rule is not to use toString() for behavior unless it "makes sense" to do so, which is not a rule at all.
by EpicEng 7y ago
Ok, but then the rule is not to use toString() for behavior unless it "makes sense" to do so, which is not a rule at all.
- asveikau 7y agoI think that misses my point. It's an established pattern recognizable to anyone who has read or written a lot of code. And locality of use and declaration is high. The danger of it being mixed up with another type in a refactor in faraway code is low. Whereas in the general case, where code can be sparse and types can be more freely altered, you could very easily change the type of something and not realize that a ToString() call on that type lurks somewhere else in the code base.