October 2018
Intermediate to advanced
370 pages
9h 15m
English
When the sole responsibility of the class is to hold some data, the data should be in presentable form. A data class provides the toString() function to display well-formatted class properties. Let's have a look at an example:
data class Person(var name : String, var age: Int, var height: Double)
println("Name ${person.name}, Age ${person.age} Height ${person.height}")
Check the following example:
ClassName (property=value)fun main(args: Array<String>) { ...Read now
Unlock full access