This topic describes the syntax, description, parameters, and response parameters of dictionary functions. This topic also provides examples of these functions.
set
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 |
|
| Response parameters | Returns a value of true. Response parameters of Example 1 and Example 2:
|
get
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 | |
| Response parameters | If the function succeeds, the value that corresponds to the specified key is returned. Otherwise, a value of false is returned. Response parameters of this example: |
foreach
Details about this function:
- Traverses elements in a dictionary (d) and calls a callback function (f) for each element.
- Specify the f parameter in the syntax of
f(key, value, user_data). - When the
f()function returns false, theforeach()loop ends.
| Item | Description |
|---|---|
| Syntax | foreach(d, f, user_data) |
| Parameters |
|
| Examples |
|
| Response parameters | Returns a value of true. Response parameters of Example 1 and Example 2:
|
del
Deletes key-value pairs from a dictionary (d). The following tables describes the details about this function.
| Item | Description |
|---|---|
| Syntax | del(d, k) |
| Parameters |
|
| Examples | |
| Response parameters | Returns a value of true. Response parameter for this example: |