The names of a list or object tree's top-level children (with "" for
unnamed slots), or NULL if the root has no children or carries no names.
Arguments
- tree
(
RTree)
A tree as returned bybuild_tree().
Value
A character vector of child names, or NULL when the root is not
a list or object node or is unnamed. An empty but named list
(structure(list(), names = character(0))) returns character(0), not
NULL: the tree preserves the named/unnamed distinction (see
tree_equal()).
Examples
tree_child_names(build_tree(list(a = 1, b = 2)))
#> [1] "a" "b"
tree_child_names(build_tree(list(1, 2)))
#> NULL