![]() 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. ![]() A function parameter can accept arguments of any type, including arguments that are functions. 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. You can also use them in functions you write yourself. To take full advantage of the Kotlin Type Hierarchy, it is essential to understand how these three special types work. 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. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |