Search results
Results from the WOW.Com Content Network
Finds the size of a key/value pair table (associative array). For example, for {foo = 'foo', bar = 'bar'}, size will return 2. The function will also work on arrays, but for arrays it is more efficient to use the # operator. Note that to find the size, this function uses the pairs function to iterate through all of the keys.
This module includes a number of set operations for Lua tables. It currently has union, intersection and complement functions for both key/value pairs and for values only. . It is a meta-module, meant to be called from other Lua modules, and should not be called directly from #invo
A table is a sequence, optionally supplemented by named keys: digit["two"]="2". Several table functions like table.concat will only work with the numbered values and ignore named keys. The metatable offers a large, optional set of methods for altering table behavior. For example, you can define a table to be callable like a function.
The C API also provides some special tables, located at various "pseudo-indices" in the Lua stack. At LUA_GLOBALSINDEX prior to Lua 5.2 [21] is the globals table, _G from within Lua, which is the main namespace. There is also a registry located at LUA_REGISTRYINDEX where C programs can store Lua values for later retrieval.
In Lua, "table" is a fundamental type that can be used either as an array (numerical index, fast) or as an associative array. The keys and values can be of any type, except nil. The following focuses on non-numerical indexes. A table literal is written as { value, key = value, [index] = value, ["non id string"] = value }. For example:
A name in Lua is either an access of a local variable or a table lookup. [3] math.floor is a table lookup (of the string "floor") in the (global) math table, for example. Table lookups are slower, at runtime, than local variable lookups. Table lookups in tables such as the args table with its "specialness" are a lot slower.
Help:Lua for beginners; Help:Lua debugging – about debugging Lua modules; Wikipedia:Lua style guide – standards to improve the readability of code through consistency; Module:Sandbox provides a pseudo-namespace for experimenting with Lua modules
Help:Lua debugging – a how-to guide about debugging Lua modules; Help:Lua for beginners – basic tutorial and pointers; Wikipedia:Lua string functions – string performance considerations and limits; Wikipedia:Guide to Scribbling – how to write templates that use Scribunto/Lua