top | item 37744976

(no title)

b3morales | 2 years 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]

discuss

order

astrange|2 years ago

The 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|2 years ago

That was almost seven years ago now. It has been the String API twice as long as it has not been the API.