Last active
August 25, 2017 14:32
-
-
Save pjhjohn/5c974ed1adb7d8fef83eac6ccc319dff to your computer and use it in GitHub Desktop.
Kotlin Infix suggestion : echo
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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