Skip to content

Instantly share code, notes, and snippets.

@truedem
Created November 5, 2018 03:28
Show Gist options
  • Save truedem/87ce48e45dc7d82316d965cb7f3d03b8 to your computer and use it in GitHub Desktop.
Save truedem/87ce48e45dc7d82316d965cb7f3d03b8 to your computer and use it in GitHub Desktop.
Descriptive replacement for variable?.let{}
// oroginal:
// variable?.let { // doStuff }
// replacement:
inline fun <T:Any, R> whenNotNull(input: T?, callback: (T)->R): R? {
return input?.let(callback)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment