effect-io-ai

Package: effect
Module: Array

Array.tail

Returns all elements except the first safely, wrapped in an Option.

When to use

Use to safely get all elements after the first when the iterable may be empty.

Details

Allocates a new array via slice(1). Empty inputs return Option.none().

Example (Getting the tail)

import { Array } from "effect"

console.log(Array.tail([1, 2, 3, 4])) // Option.some([2, 3, 4])
console.log(Array.tail([])) // Option.none()

See

Signature

declare const tail: <A>(self: Iterable<A>) => Option.Option<Array<A>>

Source

Since v2.0.0