February 2018
Intermediate to advanced
350 pages
7h 35m
English
The open and abstract classes are great for creating hierarchies, but sometimes they aren't enough. Some subsets can span between apparently unrelated hierarchies, for example, birds and great apes are bipedal, and both are animals and vertebrates, but they not directly related. That is why we need a different construct and Kotlin gives us interfaces (other languages deal with this problem differently).
Our bakery goods are great, but we need to cook them first:
abstract class BakeryGood(val flavour: String) { fun eat(): String { return "nom, nom, nom... delicious $flavour ${name()}" } fun bake(): String { return "is hot here, isn't??" } abstract fun name(): String }
With our new bake() method , it will cook all our amazing ...
Read now
Unlock full access