mirror of
https://github.com/CPunch/Cosmo.git
synced 2024-11-21 23:10:05 +00:00
better iterator example
This commit is contained in:
parent
e253129e50
commit
58485d9375
@ -13,12 +13,16 @@ proto Range
|
|||||||
return nil // exit iterator loop
|
return nil // exit iterator loop
|
||||||
end
|
end
|
||||||
|
|
||||||
return self.i++, self.i
|
return self.i++
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
for i in Range(10) do
|
||||||
|
print("->" .. i)
|
||||||
|
end
|
||||||
|
|
||||||
local total = 0
|
local total = 0
|
||||||
for i, x in Range(1000000) do
|
for i in Range(1000000) do
|
||||||
total = total + i
|
total = total + i
|
||||||
end
|
end
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user