2,875
edits
No edit summary |
No edit summary |
||
Line 36: | Line 36: | ||
-- Hooks the moveNext function into the Lua 'pairs' function | -- Hooks the moveNext function into the Lua 'pairs' function | ||
function Enumerator:overridePairs() | function Enumerator:overridePairs(startIndex) | ||
self.index = | -- Get or create clean enumerator | ||
local enum = self:getEnumerator() | |||
enum.index = startIndex | |||
enum.current = nil | |||
local function iterator(t, k) | local function iterator(t, k) | ||
if | if enum:moveNext() == true then | ||
return | return enum.index, enum.current | ||
end | end | ||
return nil, nil | return nil, nil | ||
end | end | ||
return iterator, | return iterator, enum, startIndex | ||
end | end | ||
edits