is_val/has_val
#228
-
Heya, |
Beta Was this translation helpful? Give feedback.
Answered by
biojppm
Mar 16, 2022
Replies: 1 comment 1 reply
-
To clarify:
Eg: seq:
- val0
- val1
map:
key0: val0
key1: val1 Then the following holds: assert( ! tree["seq"].has_val()); // it's a container, so it does not have a val
assert( ! tree["map"].has_val()); // it's a container, so it does not have a val
assert( tree["seq"][0].has_val());
assert( tree["seq"][1].has_val());
assert( tree["seq"][0].is_val());
assert( tree["seq"][1].is_val());
assert( tree["map"][0].has_val());
assert( tree["map"][1].has_val());
assert( ! tree["map"][0].is_val()); // map member, so is_val is false because the node has a key
assert( ! tree["map"][1].is_val()); // map member, so is_val is false because the node has a key |
Beta Was this translation helpful? Give feedback.
1 reply
Answer selected by
Beliar83
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
To clarify:
has_val()
if it has a val regardless of having a key, so it is true both for sequence and map membersis_val()
if it has a val and does NOT have a key, so it is true only for sequence membersHere's the relevant code:
Eg:
Then the following holds: