October 2019
Intermediate to advanced
434 pages
11h 54m
English
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 ...
Read now
Unlock full access