WoW:API getn: Difference between revisions

From AddOn Studio
Jump to navigation Jump to search
No edit summary
 
No edit summary
Line 15: Line 15:
  > = table.getn({1,2,3,nil,5,6}) -- sequence ends at element 3 due to nil value at 4
  > = table.getn({1,2,3,nil,5,6}) -- sequence ends at element 3 due to nil value at 4
  3
  3
----
{{template:WoW API}}

Revision as of 22:15, 30 December 2005

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

Template:WoW API