WoW:API getn: Difference between revisions

From AddOn Studio
Jump to navigation Jump to search
No edit summary
(see also: tcount)
Line 1: Line 1:
{{:Lua/Libshortcut|getn|table.getn}}
From [http://lua-users.org/wiki/TableLibraryTutorial TableLibraryTutorial] of lua-users.org.
From [http://lua-users.org/wiki/TableLibraryTutorial TableLibraryTutorial] of lua-users.org.


Line 16: Line 17:
  3
  3


----
== See Also ==
{{template:WoW API}}
 
* [[tcount]]
 
{{LUA}}

Revision as of 22:19, 9 June 2006

Lua/Libshortcut From TableLibraryTutorial of lua-users.org.

table.getn(table)

This is used to determine the size of a table. The size of a table is discussed at the top of this page.

> = table.getn({1,2,3})         -- Lua will count the elements if no size is specified
3
> = table.getn({1,2,3; n=10})   -- note, n overrides counting the elements
10
> t = {1,2,3}
> table.setn(t, 10)              -- set our own size with setn()
> = table.getn(t)
10
> = table.getn({1,2,3,nil,5,6}) -- sequence ends at element 3 due to nil value at 4
3

See Also

Template:LUA