Skip to main content
Module

x/lazy/lib/lazy.ts>Lazy#lastOrDefault

A linq-like lazy-evaluation enumerable/iteration library that aims to support deno, node & browser
Latest
method Lazy.prototype.lastOrDefault
import { Lazy } from "https://deno.land/x/lazy@v1.7.3/lib/lazy.ts";

Returns the last element in the iterable, or the given default value if the iterable was empty.

Parameters

defaultValue: TElement

The value to use of the iterable was empty.

Returns

TElement

The last element in the iterable, or the default value if empty.

Returns the last element in the iterable, or the given default value if the iterable was empty.

Parameters

defaultValue: TDefault

The value to use of the iterable was empty.

Returns

TElement | TDefault

The last element in the iterable, or the default value if empty.

Returns the last element in the iterable that satisfies the given condition, or the given default value.

Parameters

defaultValue: TElement

The value to use of the iterable was empty.

predicate: BoolPredicate<TElement>

The predicate to test each element with.

Returns

TElement

The last element in the iterable, or the default value if no element satisfied the condition.

Returns the last element in the iterable that satisfies the given condition, or the given default value.

Parameters

defaultValue: TDefault

The value to use of the iterable was empty.

predicate: BoolPredicate<TElement>

The predicate to test each element with.

Returns

TElement | TDefault

The last element in the iterable, or the default value if no element satisfied the condition.