Hyperlinkv0.8.0-beta.28

Array

Array.NonEmptyArraytypeeffect/Array.ts:115
[A, ...A[]]

A mutable array guaranteed to have at least one element.

When to use

Use when mutation is acceptable and non-emptiness must be tracked at the type level.

Details

This is the mutable counterpart of NonEmptyReadonlyArray. Most Array module functions return NonEmptyArray when the result is guaranteed non-empty.

Example (Typing a mutable non-empty array)

import type { Array } from "effect"

const nonEmpty: Array.NonEmptyArray<number> = [1, 2, 3]
nonEmpty.push(4)
Source effect/Array.ts:1151 lines
export type NonEmptyArray<A> = [A, ...Array<A>]
Referenced by 74 symbols