AnyĪny in Kotlin is on the top of the hierarchy. Note that Nothing is a subtype of Unit, that's why the first compile but not the last one. Or, if you prefer, is the result value of any statement (for example println()). The Unit type in Kotlin is the equivalent to the void type in Java. We will look in detail at Unit, Nothing, and Any, and compare against their Java corresponding classes.įinally, we also consider null and how types ending with ? fit into these categories. We will investigate how can we achieve the same functionality by using Kotlin idioms. These allow for some very powerful processing of data in a very readable way, utilizing some functional programming concepts to make the process work. ![]() To take full advantage of the Kotlin Type Hierarchy, it is essential to understand how these three special types work. Java 8 introduced the concept of Streams to the collection hierarchy. It is also quite close to the Java Type System, so the interoperability is excellent.ĥ Things You Will Like in Kotlin as a Java Developer ![]() One of the reasons is its Type Hierarchy, which is both very easy to work with and extremely powerful. ![]() It should be apparent, even to the casual reader of this blog, that I really like Kotlin as a language. String of pearls How to Take Advantage of Kotlin Special Types
0 Comments
Leave a Reply. |