July 2018
Intermediate to advanced
400 pages
12h 14m
English
Every class in Kotlin descends from a common superclass, known as Any, without you having to explicitly subclass it in your code (Figure 14.2).
Figure 14.2 TownSquare type hierarchy
For example, a Room and a Player are both implicitly children of Any, which is why you can define functions that will accept either of them as parameters. If you have worked with Java, this is similar to how classes in Java subclass the java.lang.Object class implicitly.
Consider the following example of a function called printIsSourceOfBlessings. printIsSourceOfBlessings takes in an argument of type Any and uses ...