Like in Java and most other languages, we can define multiple function parameters and then pass the corresponding multiple arguments to a function.
Let's update our helloFunctions example to take both a greeting and a name parameter. To add an additional parameter, we can simply add a comma after the previous parameter and then define the new parameter name and type:
fun helloFunctions(greeting: String, name: String) {
println("$greeting $name")
}
In this example, we've added a name parameter of the String type. Now, to call helloFunctions, we must pass both the greeting and the name parameters as in the following example:
fun main(args: Array<String>) {
helloFunctions("Hello!", "Android")
}
With support for multiple function parameters, it's often likely that we will have multiple parameters of a common type. For some of these situations, there is a special syntax Kotlin provides to make working with these functions easier and more flexible.