lastWhereIndexedOptional method
The last element whose index and value satisfies test
.
Returns Optional.empty()
if no element and index satisfies test
.
Implementation
Optional<T> lastWhereIndexedOptional(bool Function(int index, T element) test) {
T? result;
var index = 0;
for (var element in this) {
if (test(index++, element)) result = element;
}
return Optional.ofNullable(result);
}