Skip to content

Instantly share code, notes, and snippets.

@abbath0767
Created September 24, 2017 13:51
Show Gist options
  • Save abbath0767/938df8c96bfe529f5cc27e0916a22ce2 to your computer and use it in GitHub Desktop.
Save abbath0767/938df8c96bfe529f5cc27e0916a22ce2 to your computer and use it in GitHub Desktop.
class A {
val b: B
val c: String = ""
fun a(value: Int) {
b.doSomething(
value,
{
c = it + "result good"
},{
c = it + "result bad"
})
}
}
class B {
fun doSomething(
value: Int,
good: (String) -> Unit,
bad: (String) -> Unit,
) {
if (value != 0) {
good(value.toString)
} else {
bad("value must be not zero!")
}
}
}
fun main() {
A a = A(B())
a.a(13)
print(a.c)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment