Skip to content

Instantly share code, notes, and snippets.

@DavidRyan
Created March 20, 2018 21:49
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 DavidRyan/66ae4cc30a26e2e80c0fd4e5ead0b40f to your computer and use it in GitHub Desktop.
Save DavidRyan/66ae4cc30a26e2e80c0fd4e5ead0b40f to your computer and use it in GitHub Desktop.
guard.kt
inline fun <Boolean> Boolean.guard(func: () -> Unit): Boolean {
if (this == true) func(); return this
}
(thing == null).guard {
return
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment