Advertisement
Guest User

Untitled

a guest
Sep 24th, 2017
61
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.40 KB | None | 0 0
  1. class A {
  2.  
  3. val b: B
  4. val c: String = ""
  5.  
  6. fun a(value: Int) {
  7. b.doSomething(
  8. value,
  9. {
  10. c = it + "result good"
  11. },{
  12. c = it + "result bad"
  13. })
  14. }
  15. }
  16.  
  17. class B {
  18. fun doSomething(
  19. value: Int,
  20. good: (String) -> Unit,
  21. bad: (String) -> Unit,
  22. ) {
  23. if (value != 0) {
  24. good(value.toString)
  25. } else {
  26. bad("value must be not zero!")
  27. }
  28. }
  29. }
  30.  
  31. fun main() {
  32. A a = A(B())
  33. a.a(13)
  34. print(a.c)
  35. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement