% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/ts-tree-select.R
\name{[[<-.ts_tree}
\alias{[[<-.ts_tree}
\title{Edit parts of a tree-sitter tree}
\usage{
\method{[[}{ts_tree}(x, i) <- value
}
\arguments{
\item{x}{A \code{ts_tree} object.}

\item{i}{A list with selection expressions, see
\code{\link[tsitter:ts_tree_select]{ts_tree_select()}} for details.}

\item{value}{An R expression to serialize or
\code{\link[tsitter:ts_tree_deleted]{ts_tree_deleted()}}.}
}
\value{
The modified \code{ts_tree} object.
}
\description{
The \verb{[[<-} operator works similarly to the combination of
\code{\link[tsitter:ts_tree_select]{ts_tree_select()}} and
\code{\link[tsitter:ts_tree_update]{ts_tree_update()}}, (and also to the
replacement function \code{\link[tsitter:ts_tree_select<-]{ts_tree_select<-()}}),
but it might be more readable.
}
\details{
The following two expressions are equivalent:

\if{html}{\out{<div class="sourceCode r">}}\preformatted{tree <- ts_tree_update(ts_tree_select(tree, <selectors>), value)
}\if{html}{\out{</div>}}

and

\if{html}{\out{<div class="sourceCode r">}}\preformatted{tree[[list(<selectors>)]] <- value
}\if{html}{\out{</div>}}
}
\examples{
\dontshow{if (requireNamespace("tsjsonc", quietly = TRUE)) withAutoprint(\{ # examplesIf}
# Create a parse tree with tsjsonc -------------------------------------
tree <- tsjsonc::ts_parse_jsonc('{"a": 13, "b": [1, 2, 3], "c": "x"}')

tree

tree[[list("a")]] <- 42
tree[[list("b", -1)]] <- ts_tree_deleted()

tree
\dontshow{\}) # examplesIf}
}
\seealso{
Other ts_tree generics:
\code{\link[=[[.ts_tree]{[[.ts_tree()}},
\code{\link[=format.ts_tree]{format.ts_tree()}},
\code{\link[=print.ts_tree]{print.ts_tree()}},
\code{\link{select-set}},
\code{\link[=ts_tree_ast]{ts_tree_ast()}},
\code{\link[=ts_tree_delete]{ts_tree_delete()}},
\code{\link[=ts_tree_dom]{ts_tree_dom()}},
\code{\link[=ts_tree_format]{ts_tree_format()}},
\code{\link[=ts_tree_insert]{ts_tree_insert()}},
\code{\link[=ts_tree_new]{ts_tree_new()}},
\code{\link[=ts_tree_query]{ts_tree_query()}},
\code{\link[=ts_tree_select]{ts_tree_select()}},
\code{\link[=ts_tree_sexpr]{ts_tree_sexpr()}},
\code{\link[=ts_tree_unserialize]{ts_tree_unserialize()}},
\code{\link[=ts_tree_update]{ts_tree_update()}},
\code{\link[=ts_tree_write]{ts_tree_write()}}
}
\concept{ts_tree generics}
