Difference between revisions of "table"

(Created page with 'The table type implements associative arrays. An associative array is an array that can be indexed not only with numbers, but also with strings or any other value of the language…')
 
 
(3 intermediate revisions by 2 users not shown)
Line 1: Line 1:
The table type implements associative arrays. An associative array is an array that can be indexed not only with numbers, but also with strings or any other value of the language, except nil. Moreover, tables have no fixed size; you can add as many elements as you want to a table dynamically. Tables are the main (in fact, the only) data structuring mechanism in Lua, and a powerful one. See [http://www.lua.org/pil/2.5.html Programming in Lua].
+
From the Lua 5.1 [http://www.lua.org/manual/5.1/manual.html#2.2 reference manual §2.2]:
 +
 
 +
The type table implements associative arrays, that is, arrays that can be indexed not only with [[number]]s, but with any value (except [[nil]]). Tables can be heterogeneous; that is, they can contain values of all types (except [[nil]]). Tables are the sole data structuring mechanism in Lua; they can be used to represent ordinary arrays, symbol tables, sets, records, graphs, trees, etc. To represent records, Lua uses the field name as an index. The language supports this representation by providing a.name as syntactic sugar for a["name"]. There are several convenient ways to create tables in Lua (see [http://www.lua.org/manual/5.1/manual.html#2.5.7 §2.5.7]).
 +
 
 +
[[Category:Lua]]
 +
== Other Languages ==
 +
{{i18n|table}}

Latest revision as of 23:05, 5 February 2012

From the Lua 5.1 reference manual §2.2:

The type table implements associative arrays, that is, arrays that can be indexed not only with numbers, but with any value (except nil). Tables can be heterogeneous; that is, they can contain values of all types (except nil). Tables are the sole data structuring mechanism in Lua; they can be used to represent ordinary arrays, symbol tables, sets, records, graphs, trees, etc. To represent records, Lua uses the field name as an index. The language supports this representation by providing a.name as syntactic sugar for a["name"]. There are several convenient ways to create tables in Lua (see §2.5.7).

Other Languages