-
-
Save abbath0767/938df8c96bfe529f5cc27e0916a22ce2 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
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