Hyperlinkv0.8.0-beta.28

Array

Array.allocateconsteffect/Array.ts:173
<A = never>(n: number): Array<A | undefined>

Creates a new Array of the specified length with all slots uninitialized.

When to use

Use when you need a pre-sized array that will be filled imperatively.

Details

Elements are typed as A | undefined because the slots are empty.

Example (Allocating a fixed-size array)

import { Array } from "effect"

const result = Array.allocate<number>(3)
console.log(result.length) // 3
constructorsmakeBy
Source effect/Array.ts:1731 lines
export const allocate = <A = never>(n: number): Array<A | undefined> => new Array(n)