15.8 Variable Number of Function Parameters
It is not always possible to know in advance the number of parameters a function will need to accept when it is called within application code. Kotlin handles this possibility through the use of the vararg keyword to indicate that the function accepts an arbitrary number of parameters of a specified data type. Within the body of the function, the parameters are made available in the form of an array object. The following function, for example, takes as parameters a variable number of String values and then outputs them to the console panel:
fun displayStrings(vararg strings: String)
{
for (string in strings) {
println(string)
}
}
displayStrings("one", "two", "three", "four")
Kotlin does not permit multiple vararg parameters within a function and any single parameters supported...