I would agree with everybody else who says an empty sequence should return true
(and your documentation comment seems to confirm that). However, to implement
the behaviour you want, there is no need to think of something clever, simply
count the number of iterations of the for loop.
func
I know this is completely not answering your question, but why wouldn't an
empty sequence return true? There is no element in an empty sequence that does
not satisfy the predicate.
As for guarding against an empty sequence, you can create a buffered sequence
type with 1-lookahead. Off the top
On Mon, May 9, 2016 at 8:21 AM, Shane S via swift-users
wrote:
> On May 9, 2016, at 6:18 AM, Adriano Ferreira
> wrote:
>
> So, I thought about “underestimatedCount” but was not sure how to use it
> properly.
>
>
> `guard self.underestimateCount > 0
On May 9, 2016, at 6:18 AM, Adriano Ferreira
> wrote:
So, I thought about “underestimatedCount” but was not sure how to use it
properly.
`guard self.underestimateCount > 0 else {return false}`
Also, about using “next”, Austin mentioned
Hi all, thanks for the replies.
So, I thought about “underestimatedCount” but was not sure how to use it
properly.
I chose to put this method on SequenceType rather than CollectionType because
I’d like it to be less restrictive since there was no need to subscripting.
Also, about using
I imagine `#underestimateCount()` is going to be your best bet, though you may
not always see the results you desire
some notes:
1. most would argue that the results you are describing are correct: it is
vacuously true that for an empty sequence _every_ element in the sequence will
satisfy