Is there any way to loop through an array without using pairs()?
snippet in lua

Is there any way to loop through an array without using pairs()?

user600

local object = {
    platform = {1,2,3,4},
    mob = {4,3,2,1}
}

function object.nameIs(idx)
    local array = object[idx]
    local i = 0
    return function ()
        i = i+1
        return array[i]
    end
end

print "-- Platforms --"
for value in object.nameIs("platform") do
    print(value)
end

print "-- Mobs --"
for value in object.nameIs("mob") do
    print(value)
end