Skip to content

Instantly share code, notes, and snippets.

@soudmaijer soudmaijer/Optional.kt
Last active May 20, 2018

Embed
What would you like to do?
val orderOrElse: Order = orderById?.apply {
// do stuff with order
} ?: Order() // orElse with default
val orderOrElseThrow: Order = orderById?.apply {
// do stuff with order
} ?: throw RuntimeException("orElseThrow") // orElseThrow
val orderId: Long? = orderById?.let {
// do stuff with order
it.id
} // Return something else than an Order
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.