Skip to content

Glossary: Kotlin Basics

toInt / toDouble / toIntOrNull / toDoubleOrNull

Also written: toInt(), toDouble(), toIntOrNull(), toDoubleOrNull(), toString()

Functions that convert text to numbers. `toInt()` crashes on bad text, while `toIntOrNull()` and `toDoubleOrNull()` give null instead. `toString()` turns a number into text.

Where the book teaches it

Related terms

NumberFormatExceptionnull