This topic describes the syntax, features, parameters, and response parameters 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) |
Parameter |
|
Example |
|
Return value | Returns a value of true. Return values of Example 1 and Example 2:
|
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) |
Parameter |
|
Example |
|
Return value | If the function succeeds, the value that corresponds to the specified key is returned.
Otherwise, a value of false is returned. Return value in this example:
|
foreach
Notes on this function:
- This function traverses elements in a dictionary (d) and calls a callback function (f) for each element.
- You must set 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) |
Parameter |
|
Example |
|
Return value | Returns a value of true. Returns values of Example 1 and Example 2:
|
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) |
Parameter |
|
Example |
|
Return value | Returns a value of true. Return value in this example:
|