singleOrEmpty

inline fun <T> Iterable<T>.singleOrEmpty(predicate: (T) -> Boolean): T?(source)

Returns the single element matching the given predicate, or null if element was not found.

Throws IllegalArgumentException when multiple elements are matching predicate.


Returns single element, or null if the collection is empty. Throws IllegalArgumentException when multiple elements are matching predicate.