Why you should totally switch to Kotlin
Magnus Vinther
1.8K39

Nice and short overview of these neat features of the Kotlin language.

I think another super awesome feature is the delegation in Kotlin. In the example you see that the Car is delegating the getBrand() without any additional Code in the body of Car to the BrandMixin.

interface HasCarBrand {
fun getBrand():String
}

class BrandMixin(val n:String): HasCarBrand {
override fun getBrand() = n
}

class Car(n: String): HasCarBrand by BrandMixin(n) {
}

fun main(args: Array<String>) {
val p = Car("VW")
println(p.getBrand())
}