February 2018
Intermediate to advanced
350 pages
7h 35m
English
Creating classes whose primary purpose is to hold data is a common pattern in Kotlin (is a common pattern in other languages too, think of JSON or Protobuff).
Kotlin has a particular kind of class for this purpose:
data class Item(val product: BakeryGood, val unitPrice: Double, val quantity: Int)
To declare data class, there are some restrictions:
With these restrictions, data classes give a lot of benefits.
Read now
Unlock full access