What are the puzzlers?

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

Exemplary puzzles

Order of nullable operators

fun main(args: Array) { 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 answer and explanation

Extensions are resolved statically

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

What does it display?

a) Doesn't compile
b) Runtime error
c) "c"
d) "d"

Show answer and explanation

We helped over 200 developers from 27 companies worldwide in smooth transition to Kotlin

Mariusz Saramak - Kt.Academy references

Mariusz Saramak

Expert Android Developer

Tom Tom

"On this workshop, I not only systematized knowledge about Kotlin syntax but also, thanks to Marcin, I changed my way of thinking about problem-solving to functional way - I got a new tool that I can use at work on a daily basis. It seems to me that whole training is focused on immediate use of new knowledge in daily work. Big +"
Patryk Grajewski - Kt.Academy references

Patryk Grajewski

Android Software Engineer

Sii Poland

"Very good workshop. Perfect for developers that want to move easily from Java to Kotlin. During the workshop, we did plenty of exercises that enabled checking new knowledge in practice."
Book practical workshops tailored to your needs