February 2019
Intermediate to advanced
442 pages
11h 46m
English
Often, the amount of data that we supply to functions or constructors varies in different use cases. The system should be flexible enough to produce the desired result even if we don't provide the values of all the parameters.
If you want to achieve this in Java, you need to write a couple of overloaded functions or constructors as per your need. You will end up writing the same method multiple times with a different set of input parameters and calling other constructors or methods with default values. This quickly results in verbose code—writing code again and again for the same thing.
Kotlin provides an intuitive solution to this scenario with the feature called the default function argument. This is as simple ...