October 2019
Intermediate to advanced
434 pages
11h 54m
English
Function parameters have names that we use to access the argument data when passed. In Kotlin, we can make use of parameter names at the function call site to control which parameter an argument value is assigned to.
Let's revisit our previous examples to better understand how to use named parameters. We'll use our helloFunctions implementation that has two parameters:
fun helloFunctions(greeting: String, name: String) { ... }
We see the two parameters, greeting and name, both of the String type. If we want to use this function, it might look something like this:
fun main(args: Array<String>) { helloFunctions("Hello", "Kotlin")}
This is very straightforward, but because both parameters are the same type, there's always the ...
Read now
Unlock full access