Kotlin HashSet singleOrNull()
Syntax & Examples
Syntax of HashSet.singleOrNull()
There are 2 variations for the syntax of HashSet.singleOrNull() extension function. They are:
1.
fun <T> Iterable<T>.singleOrNull(): T?
This extension function returns single element, or null if the collection is empty or has more than one element.
2.
fun <T> Iterable<T>.singleOrNull( predicate: (T) -> Boolean ): T?
This extension function returns the single element matching the given predicate, or null if element was not found or more than one element was found.