Hyperlinkv0.8.0-beta.28

Array

Array.appendconsteffect/Array.ts:644
<B>(last: B): <A>(self: Iterable<A>) => NonEmptyArray<A | B>
<A, B>(self: Iterable<A>, last: B): NonEmptyArray<A | B>

Adds a single element to the end of an iterable, returning a NonEmptyArray.

When to use

Use when you need to guarantee a non-empty result after adding a required trailing value.

Example (Appending an element)

import { Array } from "effect"

const result = Array.append([1, 2, 3], 4)
console.log(result) // [1, 2, 3, 4]
Source effect/Array.ts:6444 lines
export const append: {
  <B>(last: B): <A>(self: Iterable<A>) => NonEmptyArray<A | B>
  <A, B>(self: Iterable<A>, last: B): NonEmptyArray<A | B>
} = dual(2, <A, B>(self: Iterable<A>, last: B): Array<A | B> => [...self, last])
Referenced by 2 symbols