July 2018
Intermediate to advanced
336 pages
9h 23m
English
Kotlin supports a variable number of arguments in functions as in the following code:
fun sum(vararg nos: Int): Int { var result = 0; for(no in nos) { result+= no; } return result;}
These can be invoked with a varying number of arguments, such as the following code:
println("Sum of 1, 2, 3 is ${sum(1, 2, 3)}");println("Sum of 0, 9, 8, 7, 6, 5, 4, 3, 2, 1 is ${sum(0, 9, 8, 7, 6, 5, 4, 3, 2, 1)}");
Read now
Unlock full access