Returns the last element in the source that satisfies the predicate or a default value if no such element is found.
Type of items in the source.
Default value to return if no element is found.
Predicate function to determine if an element should be returned.
Collector that returns the last element in the source that satisfies the predicate or a default value if no such element is found.
const result = lastOrDefault<number>(0, (x) => x > 1)([1, 2, 3]);console.log(result); // 3 Copy
const result = lastOrDefault<number>(0, (x) => x > 1)([1, 2, 3]);console.log(result); // 3
Returns the last element in the source that satisfies the predicate or a default value if no such element is found.