Kong Gateway (Enterprise)
2.1.x
You are browsing documentation for an outdated version. See the
latest documentation here.
kong.table
kong.table
Utilities for Lua tables
kong.table.new([narr[, nrec]])
Returns a table with pre-allocated number of slots in its array and hash parts.
Parameters
- narr (number, optional): specifies the number of slots to pre-allocate in the array part.
- nrec (number, optional): specifies the number of slots to pre-allocate in the hash part.
Returns
table
the newly created table
Usage
1
local tab = kong.table.new(4, 4)
kong.table.clear(tab)
Clears a table from all of its array and hash parts entries.
Parameters
- tab (table): the table which will be cleared
Returns
- Nothing
Usage
1
2
3
4
5
6
7
8
9
local tab = {
"hello",
foo = "bar"
}
kong.table.clear(tab)
kong.log(tab[1]) -- nil
kong.log(tab.foo) -- nil