Skip to content

Instantly share code, notes, and snippets.

@soudmaijer
Last active May 18, 2018 20:02
Show Gist options
  • Save soudmaijer/56aa28c0bce56a37d8f9af35cbd40104 to your computer and use it in GitHub Desktop.
Save soudmaijer/56aa28c0bce56a37d8f9af35cbd40104 to your computer and use it in GitHub Desktop.
fun doStuffWithOrder(id: Long) {
val orderById: Order? = orderRepository.findOrderById(id)
orderById?.run {
// do stuff with order
}
orderById.id // Compiler error: Only safe ?. or non-null asserted calls are allowed on a nullable receiver of type Order?
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment