Maybe you were looking for the Enterprise Documentation instead?
Careful! You are browsing documentation for an outdated version of Kong. Go here to browse the documentation for the latest version.

Table of Contents

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

local tab = kong.table.new(4, 4)

Back to TOC

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

local tab = {
  "hello",
  foo = "bar"
}

kong.table.clear(tab)

kong.log(tab[1]) -- nil
kong.log(tab.foo) -- nil

Back to TOC