cleanup, docs
This commit is contained in:
@@ -6,6 +6,7 @@ f : callback invoked for each child, or once for a scalar value
|
||||
return value : none
|
||||
|
||||
:see
|
||||
>types
|
||||
0_DValue
|
||||
2_DValue_map
|
||||
2_DValue_filter
|
||||
@@ -16,8 +17,10 @@ Iterates a `DValue` without modifying it. References are dereferenced before ite
|
||||
|
||||
For map-shaped values, the callback receives each child and its key. List-shaped maps iterate in numeric index order (`0`, `1`, `2`, ...); ordinary maps iterate in `std::map` string-key order. Scalar values invoke the callback once with the current value and an empty key.
|
||||
|
||||
```cpp
|
||||
rows.each([&](const DValue& row, String key) {
|
||||
print(key, ": ", row.get_by_path("title").to_string("Untitled"), "\n");
|
||||
});
|
||||
```
|
||||
:example
|
||||
DValue user;
|
||||
user["name"] = "Ada";
|
||||
user["role"] = "admin";
|
||||
StringList keys;
|
||||
user.each([&](const DValue& item, String key) { keys.push_back(key); });
|
||||
print(join(keys.sort(), ","), "\n");
|
||||
|
||||
Reference in New Issue
Block a user