Jump to content

Module:table/sparseIpairs

Wiktionary වෙතින්


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
"https://si.wiktionary.org/w/index.php?title=Module:table/sparseIpairs&oldid=221496" වෙතින් සම්ප්‍රවේශනය කෙරිණි