Different ways of calling a function
Sometimes we need to call a function and provide only selected arguments. In Java, we could create multiple overloads of the same method, but this solution has some limitations. The first problem is that the number of possible permutations of a given method is growing very quickly (2n), making them very difficult to maintain. The second problem is that overloads must be distinguishable from each other, so the compiler may know which overload to call. So when a method defines a few parameters with the same type, we can't define all possible overloads. That's why in Java we often need to pass multiple null values to a method:
// Java printValue("abc", null, null, "!");
Multiple null parameters provide boilerplate. Such a situation greatly decreases method readability. In Kotlin, there is no such problem, because Kotlin has a feature called default arguments and named argument syntax.
Default argument values
Default arguments are mostly known from...