Making functions flexible
As functions are the building blocks of our code, they need to be versatile to cater for anything we might need to do. We have already seen how we can create very varied parameter lists and return types, as well as deciding in code when to return to the calling code. As we progress, you will see that we need even more options. What follows is a quick glance at some more Kotlin function options that we will introduce now, and then get around to using for real at various points throughout the book.
Default and named arguments
A default parameter is where we the programmers provide a value (default) for a parameter that will be used if the code that calls the function does not provide it. A named argument is when the code calling a function specifies a name along with a value. Note that providing a value is optional. Just because a default value for a parameter is given does not prevent the calling code from overriding it by providing it. Have a look at the following...