Inlay Hints

In some of the screenshots of Kotlin code shown in this book, you may have noticed “inlay hints”:

Kotlin Code Snippet with Inlay Hints Highlighted
Kotlin Code Snippet with Inlay Hints Highlighted

In Kotlin, we do not have to manually enter a lot of the data types that we would in Java — Kotlin’s compiler infers the types on its own. However, that does mean that we have a bunch of variables and properties for which there is no type information in our code, which makes reading that code a bit more difficult.

We can enable “inlay hints”, though. That causes Android Studio to use the compiler-inferred types, displaying them inline as if we had typed them in. The actual source code does not contain the hints, and they are not editable as text. They simply act as markers, to show you what the types are.

In “Editor” > “Inlay Hints” > “Kotlin”, you can decide whether to show inlay hints and for what scenarios you want them to appear:

Settings Dialog, Showing Inlay Hints Options for Kotlin
Settings Dialog, Showing Inlay Hints Options for Kotlin

Prev Table of Contents Next

This book is licensed under the Creative Commons Attribution-ShareAlike 4.0 International license.