Hyperlinkv0.8.0-beta.28

Array

Array.headNonEmptyconsteffect/Array.ts:1109
<A>(self: NonEmptyReadonlyArray<A>): A

Returns the first element of a NonEmptyReadonlyArray directly (no Option wrapper).

When to use

Use to get the first element without Option wrapping when the array is known to be non-empty.

Example (Getting the head of a non-empty array)

import { Array } from "effect"

console.log(Array.headNonEmpty([1, 2, 3, 4])) // 1
gettershead
Source effect/Array.ts:11091 lines
export const headNonEmpty: <A>(self: NonEmptyReadonlyArray<A>) => A = getUnsafe(0)
Referenced by 8 symbols