If you already have an array that contains the values that you would want
to pass to a vararg
function, you can use the "spread operator" (*
) as
a prefix to the array. Then, instead of treating the array as a single "vararg",
Kotlin will expand the array and consider each of its members to be a "vararg"
parameter.
So, in this example, the capped()
function gets an array with the same contents
as is in things
.
You can learn more about this in:
Tags: