[swift-users] Guarding against an empty sequence
Dmitri Gribenko
gribozavr at gmail.com
Mon May 9 11:13:58 CDT 2016
On Mon, May 9, 2016 at 8:21 AM, Shane S via swift-users
<swift-users at swift.org> wrote:
> On May 9, 2016, at 6:18 AM, Adriano Ferreira <adriano.ferreira at me.com>
> wrote:
>
> So, I thought about “underestimatedCount” but was not sure how to use it
> properly.
>
>
> `guard self.underestimateCount > 0 else {return false}`
`underestimateCount` is what it says, an underestimate. A non-empty
sequence can return 0.
Dmitri
--
main(i,j){for(i=2;;i++){for(j=2;j<i;j++){if(!(i%j)){j=0;break;}}if
(j){printf("%d\n",i);}}} /*Dmitri Gribenko <gribozavr at gmail.com>*/
More information about the swift-users
mailing list