noneOrSingle

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

Returns the single element matching the given predicate, or null if the collection is empty, or throws exception if more than one element was found.


fun <T> List<T>.noneOrSingle(): T?

Returns the single element, or null if the list is empty, or throws an exception if it has more than one element.