[swift-evolution] [Draft] Rename Sequence.elementsEqual

Brent Royal-Gordon brent at architechies.com
Fri Oct 13 20:45:16 CDT 2017


> On Oct 12, 2017, at 9:57 PM, Kevin Nattinger via swift-evolution <swift-evolution at swift.org> wrote:
> 
> That is reflected in the fact that over half the methods in the main Sequence definition* make no sense and are not well-defined unless there is a well-defined order to the sequence itself. What does it even mean to `dropFirst()` in a Set?

It means to skip the first element the set would normally have given you. Which element this will be may be arbitrary, but this is still not useless:

    set.dropFirst().reduce(set.first!, …)

Even elementsEqual(_:) does tell you something potentially valuable: Whether two instances will end up giving the same result when processed by an ordering-sensitive algorithm.

We should change the name to something like orderEquals(_:), and maybe change the lexicographicallyPrecedes(_:) method to something analogous like orderPrecedes(_:), and then be done with it. 

-- 
Brent Royal-Gordon
Sent from my iPhone



More information about the swift-evolution mailing list