The Data Objects and Constants

Explore the use of data objects and constants to enhance code readability and optimization.

The data object declarations

Since Kotlin 1.8, we can use the data modifier for object declarations. It generates the toString method for the object; this method includes the object name as a string.

Get hands-on with 1200+ tech skills courses.