Kotlin: Data Type Conversions

From time to time, you might need to convert (i.e. casting) a variable from one data type to another. Example such as converting a string to a number. Kotlin contains predefined functions that allows you to do the data type conversions easily.

  • toByte()
  • toShort()
  • toInt()
  • toLong()
  • toFloat()
  • toDouble()
  • toChar()
  • toString()