Learning Kotlin: ‘lateinit’ Modifier

This Kotlin tutorial explores the lateinit modifier and gives several examples of how you can use lateinit in Android or other Kotlin projects. lateinit allows you to defer initialization of non-null values so they can still be defined as non-null, but can be assigned later as in many dependency injection or test frameworks. ex: lateinit Continue reading Learning Kotlin: ‘lateinit’ Modifier

Learning Kotlin: Type Aliases

Type aliases in Kotlin allow you to provide alternative names for existing types. This is particularly useful for shortening long type names, or for providing more semantic meaning to existing types. For example, instead of using ‘String’ you could create a type alias called ‘UserId’ that provides more information about the expected usage of that Continue reading Learning Kotlin: Type Aliases

Learning Kotlin: ‘Const’ Modifier

Kotlin’s ‘const’ modifier allows you to mark a variable as a true, JVM compile-time constant. To do this, the variable must meet several requirements. 1. Must be a top-level variable or a variable on an Object 2. Must be a String or primitive type 3. No custom getter 0:30 Example case study 1:18 Examine bytecode Continue reading Learning Kotlin: ‘Const’ Modifier

Learning Kotlin: View Kotlin Bytecode

You can easily view the bytecode for the Kotlin you write, and then decompile that bytecode into more readable Java code. This is useful for understanding what the Kotlin compiler is doing behind the scenes. Thoughts, questions, tips on examining Kotlin bytecode and the decompiled Java equivalent? Comment below or share on social media. I’d Continue reading Learning Kotlin: View Kotlin Bytecode

Learning Kotlin: nullability

Wondering how to handle null in Kotlin? Kotlin strictly differentiates between null and non-null types. This is great because it forces developers to consider when & where to use null. In this video, you’ll learn the basics of defining null variables, defining null parameters, and checking for null values. 0:08 How Kotlin handles null 0:30 Continue reading Learning Kotlin: nullability