arrow-core-data / arrow.core / Option / findOrNull

findOrNull

inline fun findOrNull(predicate: (A) -> Boolean): A?

Returns the $option’s value if this option is nonempty ‘'’and’’’ the predicate $p returns true when applied to this $option’s value. Otherwise, returns null.

Example:

Some(12).exists { it > 10 } // Result: 12
Some(7).exists { it > 10 }  // Result: null

val none: Option<Int> = None
none.exists { it > 10 }      // Result: null

Do you like Arrow?

Arrow Org
<