Skip to content

Instantly share code, notes, and snippets.

@leonardoaramaki
Created June 9, 2017 16:29
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/902738960d10742ef3f4d2ea4a86aad0 to your computer and use it in GitHub Desktop.
Save leonardoaramaki/902738960d10742ef3f4d2ea4a86aad0 to your computer and use it in GitHub Desktop.
fun fail(message: String): Nothing {
throw IllegalStateException(message)
}
// ...
val user: User = getUser() ?: fail("User not found!")
println("Hello, ${user.name}")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment