Skip to content

Instantly share code, notes, and snippets.

@aballano
Created March 29, 2017 12:54
Show Gist options
  • Save aballano/371c888bd522f149483b1d251585f663 to your computer and use it in GitHub Desktop.
Save aballano/371c888bd522f149483b1d251585f663 to your computer and use it in GitHub Desktop.
sealed class Option<out A> {
object None : Option<Nothing>()
data class Some<out A>(val value: A) : Option<A>()
inline fun <B> map(f: (A) -> B): Option<B> = when (this) {
is None -> this
is Some -> Some(f(value))
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment