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

getFirst

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

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

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

Tries to find first 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