push_back: Push an Element to the Back

View source: R/30-api-flexseq-ends.R

push_backR Documentation

Push an Element to the Back

Description

Returns a new sequence with value appended at the right end.

Usage

push_back(x, value)

Arguments

x

A flexseq.

value

Element to append.

Details

This operation is persistent: x is not modified.

Elements can be named, but only if all are uniquely named (no missing names).

Value

Updated flexseq.

Examples

s <- as_flexseq(letters[1:3])
s2 <- push_back(s, "d")
s2
s  # unchanged

n <- as_flexseq(list(two = 2, three = 3))
new_el <- 4
names(new_el) <- "four"
push_back(n, new_el)

# Named/unnamed mixes are rejected
try(push_back(n, 5))

Immutables documentation built on April 29, 2026, 1:06 a.m.