Module:Util/tables/len: Difference between revisions

From Zelda Wiki, the Zelda encyclopedia
Jump to navigation Jump to search
m (PhantomCaleb moved page Module:Util/tbl/len to Module:Util/tables/len without leaving a redirect)
mNo edit summary
Line 1: Line 1:
local clone = require("Module:Util/tbl/clone")
local clone = require("Module:Util/tables/clone")


local function len(array)
local function len(array)

Revision as of 17:40, 5 May 2024

len(tbl)

Returns

  • The length of the array component of tbl. Unlike the # operator, this function works with frame.args and tables loaded via mw.loadData.

Examples

#InputOutputResult
1
len({1, 2, 3, [10] = 10})
3
Green check.svg
2
len({ foo = "bar" })
0
Green check.svg

local clone = require("Module:Util/tables/clone")

local function len(array)
	-- The # operator won't work on tables loaded via mw.loadData so we have to clone them first
	return #clone(array)
end

return len