3 ms·
The issue with the default syntax in NSString is that the mutating methods are the more concise, but are also the ones you use the least. It makes far more sens
by thingsdoer 13y ago
The issue with the default syntax in NSString is that the mutating methods are the more concise, but are also the ones you use the least. It makes far more sense for the more used methods to be more concise than their mutating siblings.
I don't disagree with you though. I'd prefer if the interface for this was more idiomatic.
Returning void is sort of pointless. A boolean, maybe. I feel like returning self is just making better use of things, really, and probably doesn't really cause any confusion.
- jakobe 13y agoOkay, now I get it, the naming makes autocomplete more convenient. Returning void makes it easier to spot errors. If you accidentally use "capitalizeInPlace" instead of "capitalizedString" your code will compile without issues. If the mutating method returned void, it would result in a compile error.
- thingsdoer 13y agoThat's an extreme edge case though, since if you're using a mutating method, you're using a mutating string, and you're probably aware of that.