This topic describes the syntax, features, parameters, and return values of dictionary functions. This topic also provides examples of these functions.
set
This function sets key-value pairs in a dictionary specified by the d parameter. The following table describes the details about this function.
Item | Description |
Syntax | set(d, k, v) |
Parameters |
|
Examples |
|
Return values | Returns a value of true. In this example, the following values are returned:
|
get
This function retrieves the value (v) that corresponds to a key (k) from a dictionary (d). The following table describes the details about this function.
Item | Description |
Syntax | get(d, k) |
Parameters |
|
Examples |
|
Return values | If the function succeeds, the value that corresponds to the specified key is returned. Otherwise, a value of false is returned. In this example, the following values are returned:
|
foreach
Notes on this function:
This function traverses elements in a dictionary (d) and calls a callback function (f) for each element.
Set the f parameter in the syntax of
f(key, value, user_data)
.When the
f()
function returns false, theforeach()
loop ends.
The following table describes the details about this function.
Item | Description |
Syntax | foreach(d, f, user_data) |
Parameters |
|
Examples |
|
Return values | Returns a value of true. In this example, the following values are returned:
|
del
This function deletes key-value pairs from a dictionary (d). The following table describes the details about this function.
Item | Description |
Syntax | del(d, k) |
Parameters |
|
Examples |
|
Return values | Returns a value of true. In this example, the following values are returned:
|