Mô đun:table/sparseIpairs
Giao diện
- Trang mô đun này thiếu trang con tài liệu. Xin hãy tạo trang tài liệu này.
- Liên kết hữu ích: trang gốc • trang con của trang gốc • liên kết • nhúng • trường hợp kiểm thử • chỗ thử
local table_num_keys_module = "Module:table/numKeys"
local function num_keys(...)
num_keys = require(table_num_keys_module)
return num_keys(...)
end
--[==[
An iterator which works like `ipairs`, but which works for sparse arrays.]==]
return function(t)
local keys, i = num_keys(t), 0
return function()
i = i + 1
local k = keys[i]
if k ~= nil then
return k, t[k]
end
end
end