3 ms·
If many languages/libraries have SortedCollection, or a collection which is always a sorted sequence, why not have something like a "TrimmedString?" It'll be a
by stcredzero 18y ago
If many languages/libraries have SortedCollection, or a collection which is always a sorted sequence, why not have something like a "TrimmedString?" It'll be a string that's always in the trimmed state. That would eliminate lots of "trim()" calls.
- DougBTX 18y agoPresumably it would require magic to handle foo + " " + bar
- stcredzero 18y agoIf foo contains an instance TrimmedString, why can't it just return itself after the first + operation? If you send a TrimmedString to a String, then all bets are off. This would make the use case: if you start with a TrimmedString, you always have a TrimmedString. (Barring operations that are deliberate conversions.)
- shrughes 18y agoBecause if foo contains "f" and bar contains "b", then your scheme would have (foo + " " + bar) contain "fb" and not "f b"
- stcredzero 18y agoThen the fool should use a regular String! RTFM!
- jongraehl 18y agono problem - types for left-trimmed, right-trimmed, and both-trimmed ;)