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