About Sequence.Filtered

[Skipped out on these forums for a month. Nowhere near catching up.]

Inspired by one of the few WWDC-2018 videos I've seen, I've looked through the recent evolution proposals and saw SE-0174, "Change filter to return an associated type." Why isn't SubSequence being used as the return type? Did the author forget, or is there a more subtle reason?

1 Like

SubSequence is a contiguous portion of Self. Everything that uses it—like slicing, drop(while:), and split(maxSplits:omittingEmptySubsequences:whereSeparator:)—returns sequences of adjacent elements from self. filter(_:) doesn't do that—it can include or exclude any element anywhere in the sequence—so it can't return a SubSequence.