Module lib.container.defaulttable
DefaultTable - a table which provides a default value initialization for each key
Functions
new (initial) | Create a table where every key is inialized with a default value when first accessed. |
Functions
- new (initial)
-
Create a table where every key is inialized with a default value when first
accessed.
Providing a table as the initial value will result in a shallow copy of the given table being made when a key is initially accessed. Providing a (zero argument) function will result in the function being called to obtain the initial value. Providing any other value will result in that value being used as the initial value for keys (which could result structural sharing between keys).
Parameters:
- initial anything Value initializer (can be nil).
Returns: