November 2018
Intermediate to advanced
388 pages
9h 5m
English
We can use a named argument to invoke a function and pass the arguments by naming them. Since the arguments are named, the order doesn't need to be maintained.
Let's take a look at the following example. Consider the code for 6f_NamedArguments.kts:
fun welcome(name: String, msg:String = "Hey") { println("$msg $name")}welcome(msg = "How are you", name = "Mark")
The output is as follows:

We can also mix named arguments with arguments without a name. Consider the code for 6g_NamedArguments.kts:
fun welcome(name: String, msg:String = "Hey") { println("$msg $name")}welcome("Joseph", msg = "Hi")
The output is as follows:
In this ...
Read now
Unlock full access