The * operator is known as the Spread Operator in Kotlin.

From the Kotlin Reference:

When you call a vararg-function, you can pass arguments individually, for example asList(1, 2, 3). if you already have an array and want to pass its contents to the function, use the spread operator (prefix the array with *):

It can be applied to an Array before passing it into a function that accepts vararg.

For Example...

If you have a function that accepts a varied number of arguments...

fun sumOfNumbers(vararg numbers: Int): Int {
    return numbers.sum()
}

Use the spread operator to pass an array's elements as the arguments:

val numbers = intArrayOf(2, 3, 4)
val sum = sumOfNumbers(*numbers)
println(sum) // Prints '9'

Notes:

  • The * operator is also the multiplication operator (of course).
  • The operator can only be used when passing arguments to a function. The result of the operation cannot be stored since it yields no value (it is purely syntactic sugar).
  • The operator may confuse some C/C++ programmers at first because it looks like a pointer is being de-referenced. It isn't; Kotlin has no notion of pointers.
  • The operator can be used in-between other arguments when calling a vararg-function. This is demonstrated in the example here.
  • The operator is similar to the apply function in various functional programming languages.
Answer from byxor on Stack Overflow
🌐
Baeldung
baeldung.com › home › kotlin › kotlin basics › varargs and spread operator in kotlin
Varargs and Spread Operator in Kotlin | Baeldung on Kotlin
April 28, 2026 - The “*” behind the numbers array variable is the spread operator. Under-the-hood, Kotlin translates its varargs to Java varargs.
🌐
Medium
proandroiddev.com › kotlins-vararg-and-spread-operator-4200c07d65e1
Kotlin’s vararg and spread operator | by Tibi Csabai | ProAndroidDev
January 27, 2019 - Kotlin has pointers?” was my ... not a pointer. It’s Kotlin’s spread operator — the operator that unpacks an array into the list of values from the array....
People also ask

What does 'vararg' do in Kotlin?
The vararg keyword in Kotlin is used to define a function parameter that can accept a variable number of arguments. When a function has a vararg parameter, you can pass any number of values (zero or more) to that function, and those values are treated as an array within the function body. This provides a flexible way to handle function calls with a dynamic number of arguments.
🌐
dhiwise.com
dhiwise.com › post › the-kotlin-spread-operator-unfolding-arrays-into-arguments
Maximizing Efficiency with the Kotlin Spread Operator
What is the spread operator in Kotlin?
The spread operator in Kotlin, represented by an asterisk *, is used to 'spread' or expand an array into individual arguments, allowing you to pass them into a function that accepts a vararg parameter. This operator enables you to decompose the array into a list of values that are then passed as separate arguments to the function.
🌐
dhiwise.com
dhiwise.com › post › the-kotlin-spread-operator-unfolding-arrays-into-arguments
Maximizing Efficiency with the Kotlin Spread Operator
How to pass array to varargs in Kotlin?
To pass an array to a function that accepts vararg parameters in Kotlin, you need to use the Kotlin spread operator, which is the asterisk *. By prefixing the array with the spread operator when making the function call, the array is expanded into individual elements, allowing Kotlin to interpret them as separate arguments. Example: ```kotlin fun printVarargs(vararg numbers: Int) { numbers.forEach { print("$it ") } } fun main() { val intArray = intArrayOf(1, 2, 3) printVarargs(*intArray) } ``` In the above example, *intArray uses the spread operator to pass the array elements i
🌐
dhiwise.com
dhiwise.com › post › the-kotlin-spread-operator-unfolding-arrays-into-arguments
Maximizing Efficiency with the Kotlin Spread Operator
🌐
Medium
medium.com › @aayushid159 › java-varargs-vs-kotlin-varargs-spread-operator-in-kotlin-eb45b7a6f465
Java Varargs vs Kotlin Varargs & Spread Operator in Kotlin | by Aayushi | Medium
April 6, 2018 - In Java, you pass the array as is, whereas Kotlin requires you to explicitly unpack the array. Technically, this feature is called using a spread operator, but in practice it’s as simple as putting the * character before the corresponding argument:
🌐
DhiWise
dhiwise.com › post › the-kotlin-spread-operator-unfolding-arrays-into-arguments
Maximizing Efficiency with the Kotlin Spread Operator
June 6, 2024 - Instead of manipulating the input into a form that a function can accept, the spread operator automatically unwraps the array into the requisite format. The keyword vararg allows you to pass a variable number of arguments to a function—a list ...
🌐
Baeldung
baeldung.com › home › kotlin › kotlin arrays › convert kotlin array to varargs
Convert Kotlin Array to Varargs | Baeldung on Kotlin
March 19, 2024 - However, we can always convert other collections to typed arrays and use them with the spread operator: val listOfStrings = listOf("ab", "cd") assertTrue { concat(*listOfStrings.toTypedArray()) == "abcd" } Interestingly, unlike Java, we can place the vararg at any position in Kotlin.
🌐
BigKnol
bigknol.com › home › kotlin › kotlin vararg : function, spread operator * example
Kotlin vararg : Function, Spread Operator * Example - BigKnol
July 12, 2023 - To pass it as an argument to a vararg parameter, you can utilize the special spread operator “*”, which allows you to transmit the vararg’s contents. fun listOs(vararg names: String) { androidVersion(*names) } fun androidVersion(vararg ...
Find elsewhere
🌐
Kotlin
kotlinlang.org › docs › functions.html
Functions | Kotlin Documentation
When you call a vararg-function, ... contents to a function as a vararg parameter or as a part of it, use the spread operator by prefixing the array name with *:...
🌐
Educative
educative.io › home › courses › the ultimate guide to kotlin programming › vararg and spread
Understanding Kotlin Vararg and Spread Operators in Functions
The vararg feature of Kotlin provides a type-safe way to create functions that can receive a variable number of arguments. The spread operator is useful to explode or spread values in a collection as discrete arguments.
Top answer
1 of 5
298

The * operator is known as the Spread Operator in Kotlin.

From the Kotlin Reference:

When you call a vararg-function, you can pass arguments individually, for example asList(1, 2, 3). if you already have an array and want to pass its contents to the function, use the spread operator (prefix the array with *):

It can be applied to an Array before passing it into a function that accepts vararg.

For Example...

If you have a function that accepts a varied number of arguments...

fun sumOfNumbers(vararg numbers: Int): Int {
    return numbers.sum()
}

Use the spread operator to pass an array's elements as the arguments:

val numbers = intArrayOf(2, 3, 4)
val sum = sumOfNumbers(*numbers)
println(sum) // Prints '9'

Notes:

  • The * operator is also the multiplication operator (of course).
  • The operator can only be used when passing arguments to a function. The result of the operation cannot be stored since it yields no value (it is purely syntactic sugar).
  • The operator may confuse some C/C++ programmers at first because it looks like a pointer is being de-referenced. It isn't; Kotlin has no notion of pointers.
  • The operator can be used in-between other arguments when calling a vararg-function. This is demonstrated in the example here.
  • The operator is similar to the apply function in various functional programming languages.
2 of 5
39

In addition to the answers that were directly towards "what is this thing!?!", you often have the case where you have a List and want to pass it to a function that is expecting a vararg. For this, the conversion is:

someFunc(x, y, *myList.toTypedArray())

Assuming that last parameter of someFunc is vararg of the same type as the elements in the list.

🌐
DhiWise
dhiwise.com › post › kotlin-varargs-the-guide-to-flexible-function-arguments
Kotlin Varargs Explained: Enhancing Function Flexibility
May 20, 2024 - This transformation is typically ... To bridge this gap, Kotlin provides the spread operator, denoted by an asterisk *, which unpacks the contents of an array or a list into distinct arguments....
🌐
Kotlin-quick-reference
kotlin-quick-reference.com › 130-R-vararg-parameters.html
vararg parameters · Kotlin Quick Reference
The solution is that you need to pass the array into your vararg parameter with this syntax: ... The * character in this use is known as the “spread operator.” The spread operator lets you convert arrays — well, most arrays — so they can be passed into a vararg parameter.
🌐
Medium
medium.com › @sujathamudadla1213 › varargs-in-kotlin-69fbd89a01eb
varargs in Kotlin?. In Kotlin, the vararg modifier is used… | by Sujatha Mudadla | Medium
July 11, 2023 - In this case, the spread operator * unpacks the elements of the numberArray and passes them as separate arguments to the printNumbers function. It’s important to note that a function can have at most one vararg parameter, and it must be the ...
🌐
Allthingskotlin
allthingskotlin.com › varargs-and-spread
Varargs and spread – All Things Kotlin
The same conversion counts as for vararg: you can spread Array<out T> for non-primitives, or IntArray for example when Int arguments are required.
🌐
Reddit
reddit.com › r/kotlin › help me understand the spread operator
r/Kotlin on Reddit: Help me understand the spread operator
July 26, 2021 -

Hey all,

Been learning Kotlin (my background is Python)!
I was pretty happy to see that Kotlin has a very similar operation to unpack a collection of items (*).

That being said, I couldn't really find the exact reason why the spread operator only supports Arrays and not other types of collections like Lists? From my understanding, the main difference between List and and arrays is that Arrays are mutable whereas Lists are not by default (you'd have to call a mutableListOf), and arrays are fixed in size.

Where does this limitation come from?

🌐
Commonsware
klassbook.commonsware.com › lessons › Collections › spread-operator.html
Klassbook: Spread Operator - CommonsWare
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 ...
🌐
TopJavaTutorial
topjavatutorial.com › kotlin › kotlin-vararg-functions-and-spread-operator
Kotlin vararg functions and Spread(*) operator - TopJavaTutorial
December 14, 2018 - When we already have an array, it can be passed as varargs using Spread operator. In Kotlin, * operator is the Spread operator.
🌐
TMS Outsource
tms-outsource.com › home › what are kotlin varargs and how to use them
What Are Kotlin Varargs and How to Use Them - TMS Outsource
April 3, 2026 - You have an existing array. You want to pass its contents to a function that expects vararg. Kotlin won’t let you just hand over the array directly. That’s what the spread operator () is for.
🌐
The Kotlin Primer
kotlinprimer.com › basics › functions-continued › variable-number-of-arguments
🚙 · Variable number of arguments | The Kotlin Primer
December 10, 2023 - Unlike Java, Kotlin has the spread operator, denoted by *. This allows you to "splice" an array (not a list!) into a vararg parameter:
🌐
CodeSignal
codesignal.com › learn › courses › writing-functions-using-kotlin › lessons › understanding-varargs-in-kotlin-functions
Understanding Varargs in Kotlin Functions
The * in front of the names argument is the spread operator. Quick Lesson Summary and Upcoming Practice Exercises · Congratulations on mastering varargs in Kotlin! We've explored in-depth— understanding varargs, declaring them with vararg, and using them in function definitions.