```fun main() { println("%s %s".format("hi", "...
# getting-started
m
Copy code
fun main() {
    println("%s %s".format("hi", "bye"))
    println("%s %s".format(*arrayOf("hi", "bye")))
    println("%s %s".format(arrayOf("hi", "bye"))) // java.util.MissingFormatArgumentException: Format specifier '%s'
}
Anyone know why it goes wrong with a pure array declaration?
e
unlike Java,
.format(x)
doesn't change behavior based on whether
x
is an array or not
in your third case, the function is actually receiving
arrayOf(arrayOf("hi", "bye"))
(the outer array being generated by the compiler, same as in the first case)
m
ah yes I see, since the argument accepts a varargs of Any? It just accepts the input itself as the Any?
r
Think about what would be passed if you wrote
Copy code
println("%s %s".format(arrayOf("hi", "bye"), arrayOf("1", "2")))
and in what ways it is similar to your third case