September 2018
Intermediate to advanced
386 pages
11h 17m
English
The destructuring declaration is nothing but a stylish way to extract the data from the model classes at the time of creation. Often, we wrap the data in a model and return it via a function. And on the caller end, we simply access its objects one by one. We actually never wanted an entire class here.
From the statistics object, we want to read the value and the count. Our getPollStatistics function cannot return multiple data, so we thought of returning a pair and we are destructuring the pair on the left hand side of assignment operator and use the unpacked data directly.
The signature of the function is as follows:
fun getPollStatistics(statistics: List<Statistics>): Pair<Int, Int>
And destructuring it and ...
Read now
Unlock full access