child: Extract or Replace Descendant of an RStatic Object

View source: R/child.R

childR Documentation

Extract or Replace Descendant of an RStatic Object

Description

This function extracts or replaces a descendant of the given node.

Usage

child(node, index)

child(node, index) <- value

Arguments

node

(ASTNode) The node from which to extract or replace the descendant.

index

(integer) The index of the descendant to extract or replace.

value

(ASTNode) The value to replace the descendant with.

Details

If index is a vector, the child function is called recursively so that descendants several levels below node are accessible.

Value

A single child node.

See Also

children to extract or replace all children at once.

Examples

code = quote_ast(mean(1, 2, 3 + x))
x = child(code, c(2, 3, 2, 2))

child(code, c(2, 3, 2, 2)) = Integer$new(4)

nick-ulle/rstatic documentation built on May 14, 2024, 8:10 p.m.