I want to know what exactly an asterisk does before a variable name in Kotlin.
I saw this (*args) in a Spring boot Kotlin example:
@SpringBootApp
As described in the documentation this is a spread operator:
When we call a vararg-function, we can pass arguments one-by-one, e.g. asList(1, 2, 3), or, if we already have an array and want to pass its contents to the function, we use the spread operator (prefix the array with *):
val a = arrayOf(1, 2, 3) val list = asList(-1, 0, *a, 4)