Package: effect
Module: Array
Applies a function to the last element of a non-empty array, returning a new array.
When to use
Use when you already know the array is non-empty and the new last element depends on the current last element.
Example (Modifying the last element)
import { Array } from "effect"
console.log(Array.modifyLastNonEmpty([1, 2, 3], (n) => n * 2)) // [1, 2, 6]
See
setLastNonEmpty — replace with a fixed valuemodifyHeadNonEmpty — modify the first elementSignature
declare const modifyLastNonEmpty: { <A, B>(f: (a: A) => B): (self: NonEmptyReadonlyArray<A>) => NonEmptyArray<A | B>; <A, B>(self: NonEmptyReadonlyArray<A>, f: (a: A) => B): NonEmptyArray<A | B>; }
Since v4.0.0