Skip to content

Instantly share code, notes, and snippets.

@felixchez
Created December 12, 2018 19:21
Show Gist options
  • Save felixchez/422b992c63546362089836d787076038 to your computer and use it in GitHub Desktop.
Save felixchez/422b992c63546362089836d787076038 to your computer and use it in GitHub Desktop.
kotlin_nullable_function_callback
fun doAsyncOperation(val onCallback: ((String) -> Unit)? = null) {
// do lengthy computation operation
onCallback?.invoke("result")
}
===
doAsyncOperation()
doAsyncOperation {result -> Log.v(result)}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment