Title here
Summary here
Variadic functions can be called with any number of trailing arguments. For example, fmt.Println
is a common variadic function.
Here’s a function that will take an arbitrary number of int
s as arguments.
Within the function, nums
is a list of integers. We can use list-processing functions: print each element and calculate the sum.
Variadic functions can be called in the usual way with individual arguments.
If you already have multiple args in a list, you can pass them directly as in this example.