August 2017
Intermediate to advanced
440 pages
10h
English
Generated methods contain the names and values of all properties declared in the primary constructor:
data class Product(var name:String, var price:Double)
val productA = Product("Spoon", 30.2)
println(productA) // prints: Product(name=Spoon, price=30.2)
We can actually log meaningful data to a console or log file, instead of the class name and memory address as in Java (Person@a4d2e77). This makes the debugging process much simpler, because we have a proper, human-readable format.
Read now
Unlock full access