Skip to content
Buy me a coffee

List

List: object

Defined in: src/immutable/ImmutableCollections.ts:776

Unmodifiable lists: random access, null elements and null queries rejected, value equality with any List.

copyOf<E>(c): List<E>

Returns an unmodifiable list of the elements of c, in its iteration order. Returns c itself when it already is a list made by List.of or List.copyOf.

E

Collection<E>

List<E>

NullPointerException if c is null or contains a null or undefined element

of<E>(…elements): List<E>

Returns an unmodifiable list of the arguments, in argument order.

E

…E[]

List<E>

NullPointerException if an element is null or undefined

ofLazy<E>(size, computingFunction): List<E>

preview. Unmodifiable random-access list of size elements, each computed by computingFunction(index) on first access and at most once. A throwing function, a null/undefined result or a recursive access for the same index throws NoSuchElementException (with the failure as cause); that index then stays failed and throws NoSuchElementException without calling the function again. subList/reversed views are lazy too; equals/hashCode/toString compute elements.

E

number

(index) => E

List<E>

IllegalArgumentException if size is negative or not an integer

NullPointerException if computingFunction is null