Lantua
1
On Swift 4.2, underestimatedCount implementation seems to be missing on a few Collection/Sequence function return-values:
let collection = Array(0..<8)
let sequence = stride(from: 0, to: 8, by: 1)
collection.underestimatedCount // 8
sequence.underestimatedCount // 8
// Sequence dropFirst
sequence.dropFirst(2).underestimatedCount // 0
// Sequence prefix, lazy or otherwise
sequence.lazy.prefix(2).underestimatedCount // 0
sequence.prefix(2).underestimatedCount // 0
// Sequence/Collection enumerated
collection.enumerated().underestimatedCount // 0
sequence.enumerated().underestimatedCount // 0
// Sequence/Collection zip
zip(collection, collection).underestimatedCount // 0
zip(sequence, sequence).underestimatedCount // 0
zip has already been discussed here
P.S.
Interestingly, while Sequence's prefix and dropFirst doesn't have the implementation, suffix and dropLast have them.
sequence.dropLast(2).underestimatedCount // 6
sequence.lazy.suffix(2).underestimatedCount // 2
sequence.suffix(2).underestimatedCount // 2
2 Likes
Some of these Sequences, like DropFirstSequence and DropWhileSequence and PrefixSequence, are recent additions.
Makes sense to add these to the PR.
1 Like