peek_at: Peek at an Element by Position

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

peek_atR Documentation

Peek at an Element by Position

Description

Returns the element at a one-based index without modifying the sequence.

Usage

peek_at(x, index)

Arguments

x

A flexseq.

index

One-based position to read.

Details

Positive integer indices beyond length(x) return NULL. Invalid indices (NA, non-integer, ⁠<= 0⁠, or length not equal to 1) error.

Value

Element at index, or NULL when index is out of bounds.

Examples

x <- flexseq("a", "b", "c")
peek_at(x, 2)
peek_at(x, 10)

try(peek_at(x, 0))

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