Option

sealed class Option<out T>(source)

Represents an optional value with map, flatMap, fold and getOrElse to transform it.

Inheritors

Types

Link copied to clipboard
object Companion

Functions

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

Filters the value if defined by the given predicate.

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

Flat-maps over the value if defined.

Link copied to clipboard
inline fun <R> fold(default: () -> R, f: (T) -> R): R

Folds this Option.

Link copied to clipboard
inline fun <T> Option<T>.getOrElse(default: () -> T): T

Get the value of this Option if defined or use the default-value provider.

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

Maps over the value if defined.