July 2018
Intermediate to advanced
242 pages
8h 6m
English
We can see the divide() function in action:
val dividend = 10val divisor = 3val (quotient, remainder) = divide(dividend, divisor)print("$dividend / $divisor = $quotient r $remainder")
The preceding code is going to print the following output:
10 / 3 = 3 r 1
Thanks to the fact that we are returning a data class instance, the DivisionResult class, we can benefit from the destructuring feature and assign the result to a set of separate variables.
Read now
Unlock full access