Skip to content

Instantly share code, notes, and snippets.

@leonardoaramaki
Last active June 10, 2017 01:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save leonardoaramaki/fa47fb89b7806ebaf3042352a936da49 to your computer and use it in GitHub Desktop.
Save leonardoaramaki/fa47fb89b7806ebaf3042352a936da49 to your computer and use it in GitHub Desktop.
fun getUser(): User? {
// ...
}
val user: User? = getUser()
if (user != null) {
println("Hello, ${user.name}")
} else {
throw IllegalStateException("User not found!")
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment