better iterator example

This commit is contained in:
CPunch 2020-12-31 13:57:02 -06:00
parent e253129e50
commit 58485d9375
1 changed files with 6 additions and 2 deletions

View File

@ -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