What a beter way to do this?

fun a(vararg options: String) {
  b(*options.toList().plus("hi").toTypedArray())
}

fun b(vararg options: String) {
}

https://pl.kotl.in/SybKYFKPN

Also why does options.plus(“hi”) not work?

Your going to need to be a little more specific. This works

https://pl.kotl.in/Byw3TtYD4

fun a(vararg options: String): String {
    return b(*options.toList().plus("hi").toTypedArray())
}

fun b(vararg options: String): String {
    return options.joinToString();
}

fun main() {
    println(a("a"))
}

EDIT: Btw I think this is what your looking for?

fun a(vararg options: String): String {
    return b(*options, "hi")
}

fun b(vararg options: String): String {
    return options.joinToString();
}

fun main() {
    println(a("a"))
}
1 Like

Since both of you linked to the kotlin playground. You can just set the language of the code snippets here to run-kotlin and the code is embedded like this

fun main(){
//sampleStart
println("hi")
//sampleEnd
}

You still need to create a main function but you can hide it with //sampleStart and //sampleEnd

1 Like

Yes thanks!