Subclass of {@link LuaValue} for representing lua tables.
Almost all API's implemented in {@link LuaTable} are defined and documented in {@link LuaValue}.
If a table is needed, the one of the type-checking functions can be used such as {@link #istable()}, {@link #checktable()}, or {@link #opttable(LuaTable)}
The main table operations are defined on {@link LuaValue} for getting and setting values with and without metatag processing:
- {@link #get(LuaValue)}
- {@link #set(LuaValue,LuaValue)}
- {@link #rawget(LuaValue)}
- {@link #rawset(LuaValue,LuaValue)}
- plus overloads such as {@link #get(String)}, {@link #get(int)}, and so on
To iterate over key-value pairs from Java, use
{@code LuaValue k = LuaValue.NIL;}while ( true ) Varargs n = table.next(k); if ( (k = n.arg1()).isnil() ) break; LuaValue v = n.arg(2) process( k, v ) }
As with other types, {@link LuaTable} instances should be constructed via one of the table constructor methods on {@link LuaValue}:
- {@link LuaValue#tableOf()} empty table
- {@link LuaValue#tableOf(int,int)} table with capacity
- {@link LuaValue#listOf(LuaValue[])} initialize array part
- {@link LuaValue#listOf(LuaValue[],Varargs)} initialize array part
- {@link LuaValue#tableOf(LuaValue[])} initialize named hash part
- {@link LuaValue#tableOf(Varargs,int)} initialize named hash part
- {@link LuaValue#tableOf(LuaValue[],LuaValue[])} initialize array and named parts
- {@link LuaValue#tableOf(LuaValue[],LuaValue[],Varargs)} initialize array and named parts
@see LuaValue