From 58485d9375cf21a0a6cd86b8704ef9d3035ab3d4 Mon Sep 17 00:00:00 2001 From: CPunch Date: Thu, 31 Dec 2020 13:57:02 -0600 Subject: [PATCH] better iterator example --- examples/iterator.cosmo | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/examples/iterator.cosmo b/examples/iterator.cosmo index c5c00e8..6a5e294 100644 --- a/examples/iterator.cosmo +++ b/examples/iterator.cosmo @@ -13,12 +13,16 @@ proto Range return nil // exit iterator loop end - return self.i++, self.i + return self.i++ end end +for i in Range(10) do + print("->" .. i) +end + local total = 0 -for i, x in Range(1000000) do +for i in Range(1000000) do total = total + i end