Hyperlinkv0.8.0-beta.28

Array

Array.copyconsteffect/Array.ts:2810
<A>(self: NonEmptyReadonlyArray<A>): NonEmptyArray<A>
<A>(self: ReadonlyArray<A>): Array<A>

Creates a shallow copy of an array.

When to use

Use to create a distinct array reference for an existing array, for example before mutating the returned array.

Details

The return type preserves NonEmptyArray. Use this when you need a distinct reference, for example before mutating the returned array.

Example (Copying an array)

import { Array } from "effect"

const original = [1, 2, 3]
const copied = Array.copy(original)
console.log(copied) // [1, 2, 3]
console.log(original === copied) // false
elementsfromIterable
Source effect/Array.ts:28104 lines
export const copy: {
  <A>(self: NonEmptyReadonlyArray<A>): NonEmptyArray<A>
  <A>(self: ReadonlyArray<A>): Array<A>
} = (<A>(self: ReadonlyArray<A>): Array<A> => self.slice()) as any
Referenced by 2 symbols