> That said I actually think it’s useful to have these methods slightly > different as if I understand them correctly they’re not strictly > non-mutating; a Sequence doesn’t guarantee that it can be consumed over and > over without changing, as it could represent a buffer or some other construct > that’s consumed as it’s accessed, so calling dropFirst() on a sequence, then > calling it again on the same sequence may not yield the same result both > times, for that you want a Collection (or a specific sequence implementation > with well defined behaviour), but for a generic sequence I don’t think you > can trust the method to be non-mutating unless you know what the sequence is > backed by, so it shouldn’t follow the rule for non-mutating methods.
`dropFirst()`, like all `Sequence` APIs, works perfectly and reliably as long as you only access the contents of the `Sequence` once. Attempting to iterate the `Sequence` more than once may or may not work, so you shouldn't do it without static knowledge of the concrete type's behavior (for instance, knowledge that it's actually a `Collection`). -- Brent Royal-Gordon Architechies _______________________________________________ swift-evolution mailing list [email protected] https://lists.swift.org/mailman/listinfo/swift-evolution
