Hyperlinkv0.8.0-beta.28

Array

Array.lastNonEmptyconsteffect/Array.ts:1159
<A>(self: NonEmptyReadonlyArray<A>): A

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

When to use

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

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

import { Array } from "effect"

console.log(Array.lastNonEmpty([1, 2, 3, 4])) // 4
getterslast
Source effect/Array.ts:11591 lines
export const lastNonEmpty = <A>(self: NonEmptyReadonlyArray<A>): A => self[self.length - 1]
Referenced by 6 symbols