SE-0207: Add a containsOnly algorithm to Sequence

Re the all family of names: one of the clear signals from the SE-0204 thread (adding lastIndex(where:) is that people really don't like mismatched APIs. Presumably this would also go for having all/contains rather than all/any.

But we really really cannot be renaming contains at this stage, purely so that we can introduce a new related method.* If you value the symmetry, this pretty much locks us in to containsOnly instead.

Personally, I don't find the symmetry all that critical, so I'd be fine with ending up with all/contains (hence that was in the original proposal). But at the same time I don't feel that all or allMatch are any better than containsOnly.

* the rename of index(where:) is a little different, since it was a clear outlier from the existing first/last family, and index(where:) didn't really fit in with it's siblings index(after:) etc which are all about index advancement, not search.

7 Likes