Advertisement
Guest User

Untitled

a guest
Jul 12th, 2017
115
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Kotlin 0.36 KB | None | 0 0
  1. fun main(args: Array<String>) {
  2.     val current = Test(null, "foobar")
  3.    
  4.     val ret = with(current) {
  5.         when {
  6.             left != null && right != null -> null
  7.             left != null -> 1
  8.             right != null -> 2
  9.             else -> 3
  10.         }
  11.     }
  12.    
  13.     println(ret)
  14. }
  15.  
  16. class Test(
  17.     val left: Any?,
  18.     val right: Any?
  19. )
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement