Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 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)
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement