An Array
can be passed as an argument vararg
by adding *
to it:
Paths.get("", *toTypedArray)
It is called the distribution operator , as I already described in another question here .
An instance List
can be converted to vararg
as follows:
val listAsArr = listOf("a", "b").toTypedArray()
Paths.get("", * listAsArr)
source
share