withChildren

fun Node.withChildren(newChildren: List<Node>): Node

Returns a copy of this node with its children replaced by newChildren.

For most NestableNodes, the copy preserves all other parameters of the original node and only swaps the children/text slot.

For leaf nodes (with no children to replace), the original node is returned unchanged and newChildren is ignored.

Return

a copy of this node with newChildren in place of its original children, or this node itself if it has no children

Parameters

newChildren

the list of nodes that should replace this node's children