Skip to content

Comment on Show HN: NSString + Rubyparent

Comments

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.

Okay, 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.

That'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.

AboutSource Built by g1lg1l

Hackerly is an independent reader for Hacker News, built on the public HN API. Not affiliated with Y Combinator.