Kt. Academy - 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 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() { printFoo(D()) }

What does it display?

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

Show answer and explanation

We helped over 250 developers from 38 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 +"
Natalia Nazaruk - Kt.Academy references

Natalia Nazaruk

IT Developer (Android)

Nordea

"I have participated in great Kotlin for Android Developers training, with extremely competent Marcin Moskala from Kt. Academy as a trainer. It was an intensive 3-days Kotlin workshop, ended with a quite difficult and thorough exam. With experience and knowledge under my belt acquired in this course, I feel confident about my future as an Android Developer."
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."