Skip to content

Instantly share code, notes, and snippets.

@Jire
Created August 23, 2016 07:25
Show Gist options
  • Save Jire/193bfb805f7cae477bb4c4b0255f0ea4 to your computer and use it in GitHub Desktop.
Save Jire/193bfb805f7cae477bb4c4b0255f0ea4 to your computer and use it in GitHub Desktop.
class Predicator<out RESULT>(val predicate: () -> RESULT?) {
operator inline fun invoke(crossinline whenTrue: RESULT.() -> Unit) {
val result = predicate() ?: return
result.whenTrue()
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment