Some

data class Some<out T>(val value: T) : Option<T> (source)

Constructors

Link copied to clipboard
constructor(value: T)

Types

Link copied to clipboard
object Companion

Properties

Link copied to clipboard
val value: T

Functions

Link copied to clipboard
fun <A> Option<A>.combine(other: Option<A>, combine: (A, A) -> A): Option<A>
Link copied to clipboard
operator fun <A : Comparable<A>> Option<A>.compareTo(other: Option<A>): Int
Link copied to clipboard
inline fun filter(predicate: (T) -> Boolean): Option<T>

Returns this $option if it is nonempty '''and''' applying the predicate $p to this $option's value returns true. Otherwise, return $none.

Link copied to clipboard
inline fun <B> Option<*>.filterIsInstance(): Option<B>

Returns an Option containing all elements that are instances of specified type parameter B.

Link copied to clipboard
inline fun filterNot(predicate: (T) -> Boolean): Option<T>

Returns this $option if it is nonempty '''and''' applying the predicate $p to this $option's value returns false. Otherwise, return $none.

Link copied to clipboard
inline fun <B> flatMap(f: (T) -> Option<B>): Option<B>

Returns the result of applying $f to this $option's value if this $option is nonempty. Returns $none if this $option is empty. Slightly different from map in that $f is expected to return an $option (which could be $none).

Link copied to clipboard
Link copied to clipboard
inline fun <R> fold(ifEmpty: () -> R, ifSome: (T) -> R): R
Link copied to clipboard
inline fun <T> Option<T>.getOrElse(default: () -> T): T

Returns the option's value if the option is nonempty, otherwise return the result of evaluating default.

Link copied to clipboard
fun getOrNull(): T?

Returns the encapsulated value A if this instance represents Some or null if it is None.

Link copied to clipboard

Returns true if the option is None, false otherwise.

Link copied to clipboard

Returns true if the option is Some, false otherwise.

inline fun isSome(predicate: (T) -> Boolean): Boolean

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

Link copied to clipboard
inline fun <B> map(f: (T) -> B): Option<B>

Returns a Some<$B> containing the result of applying $f to this $option's value if this $option is nonempty. Otherwise return $none.

Link copied to clipboard
inline fun onNone(action: () -> Unit): Option<T>

The given function is applied as a fire and forget effect if this is a None. When applied the result is ignored and the original None value is returned

Link copied to clipboard
inline fun onSome(action: (T) -> Unit): Option<T>

The given function is applied as a fire and forget effect if this is a some. When applied the result is ignored and the original Some value is returned

Link copied to clipboard
inline fun <A> Option<A>.recover(recover: OptionRaise.(None) -> A): Option<A>

Recover from any None if encountered.

Link copied to clipboard
inline fun <L> toEither(ifEmpty: () -> L): Either<L, T>
Link copied to clipboard
fun toList(): List<T>
Link copied to clipboard
fun <K, V> Option<Pair<K, V>>.toMap(): Map<K, V>
Link copied to clipboard
open override fun toString(): String