7 Working with nullable values

This chapter covers

  • Nullable types
  • Syntax for dealing with values that are potentially null
  • Converting between nullable and non-nullable types
  • Interoperability between Kotlin’s concept of nullability and Java code

By now, you’ve seen a large part of Kotlin’s syntax in action. You’ve moved beyond creating basic code in Kotlin and are ready to enjoy some of Kotlin’s productivity features that can make your code more compact and readable. One of the essential features in Kotlin that helps improve the reliability of your code is its support for nullable types. Let’s look at the details.

7.1 Avoiding NullPointerExceptions and handling the absence of values: Nullability

Nullability is a feature of the Kotlin type system ...

Get Kotlin in Action, Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.