sdk-common / com.tomtom.online.sdk.common.functional.collections / Iterables / getLast

getLast

@NonNull static fun <T : Any!> getLast(@NonNull iterable: MutableIterable<T>): Try<T>

Returns Try with last element of provided iterable or failure if iterable is empty.

@NonNull static fun <T : Any!> getLast(@NonNull iterable: MutableIterable<T>, @NonNull predicate: Predicate<T>): Try<T>

Tries to find last Iterable element that satisfies the given predicate.

Parameters

iterable - MutableIterable<T>: iterable of values that are going to be checked

predicate - Predicate<T>: predicate used for checking

- value type

Return
Try<T>: Success if a value is found, Failure otherwise