🧩 Finds the last item that matches a predicate.
Syntax
TypeScript
import { findLastIter } from '@opentf/std'; findLastIter<T>(iter: Iterable<T>, fn: (val: T) => boolean): T | undefined
Parameters
iter: The source iterable.fn: The predicate function.
Returns
The last matching item, or undefined.
Examples
TypeScript
findLastIter([1, 2, 3, 2], (x) => x === 2) //=> 2