Skip to content

Instantly share code, notes, and snippets.

@pjhjohn
Last active August 25, 2017 14:32
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 pjhjohn/5c974ed1adb7d8fef83eac6ccc319dff to your computer and use it in GitHub Desktop.
Save pjhjohn/5c974ed1adb7d8fef83eac6ccc319dff to your computer and use it in GitHub Desktop.
Kotlin Infix suggestion : echo
infix fun <T> T.echo(activity: MainActivity): T {
when (this) {
is Int -> activity.logging(Stringify.result(this), TextLogData.Type.MESSAGE)
is String -> activity.logging(this, TextLogData.Type.MESSAGE)
else -> activity.logging("Unexpected arguments for $this.echo($activity)", TextLogData.Type.MESSAGE)
}
return this
}
fun foo() = this.let { activity ->
...
val result = bar(args) echo activity
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment