Learn by doing

Train new Kotlin skills by solving practical puzzlers

What are the puzzlers?

Puzzlers are tricky programming challenges with often surprising answers. They show how bad practices can lead to problems.

Exemplary puzzlers

Order of nullable operators

fun main() { val x: Int? = 2 val y: Int = 3 val sum = x?:0 + y println(sum) }

What will it print?

a) 3

b) 5

c) 2

d) 0

Show the answer and an explanation

Order of nullable operators

open class C class D: C() fun C.foo() = "c" fun D.foo() = "d" fun printFoo(c: C) { println(c.foo()) } fun main() { printFoo(D()) }

What does it display?

a) Doesn't compile

b) Runtime error

c) "c"

d) "d"

Show the answer and an explanation