6 ms·
> There's no reason to privilege any one of these, and Swift doesn't do this. Strange thing to say: Swift String count property is the count of extended graphe
by b3morales 3y ago
> There's no reason to privilege any one of these, and Swift doesn't do this.
Strange thing to say: Swift String count property is the count of extended grapheme clusters. The documentation is explicit:
> A string is a collection of extended grapheme clusters, which approximate human-readable characters. [emphasis in original]
- astrange 3y agoThe length/count property was added after people asked for it, but it wasn't originally in the String revamp, and it provides iterators for all of the above. .count also only claims to be O(n) to discourage using it.
- b3morales 3y agoThat was almost seven years ago now. It has been the String API twice as long as it has not been the API.