Varargs
Last updated
What is Varargs?
Varargs (variable arguments) in Kotlin allow a function to accept a variable number of arguments of the same type. Instead of defining multiple function overloads for different numbers of arguments, you can use the vararg keyword in the function's parameter list. This creates a single function that can be called with any number of arguments (including zero) of the specified type, which are then accessible within the function as an array.
Free resources to learn Varargs
- Official docsVariable number of arguments (varargs)
- VideoFunction expression & vararg
More in stage 15: Standard functions
Varargs: common questions
Can I learn Varargs in Hindi?
This lesson is written in English. Once you sign in, open it in the interactive course and ask the AI tutor to explain Varargs in Hindi or Hinglish. The tutor answers from this lesson’s own text, so it stays on the syllabus, and it runs on your own Google, OpenAI or Anthropic key.
Is this Varargs tutorial for beginners?
It is lesson 47 of 153 in the free Kotlin roadmap, in stage 15, Standard functions. If you are new to Kotlin, start from stage 1 and come back here in order; if you already know the earlier stages, this lesson stands on its own.