Pass Array<String> as vararg parameter


#1

Hi guys,

There is a method in gava which accept one parameter as String…  args. I am trying to pass there app args which is Array<String> but code analyzer telling me what i cannot  do that. How i can transform args to be able to do that?

Thanks


#2

Use spread operator, see example from M2 release notes. Unfortunately, it is not described in main Koltin docs.

fun printAll(vararg a : String) {   for (item in a) println(item) } fun main(args: Array<String>) {   printAll("one", "two")   printAll(*args) }

#3

Thanks. We'll add it. Logged here:

http://youtrack.jetbrains.com/issue/KT-5499


#4

Thaks! Did not tryied yet, but looks straightforward.