Documentation
¶
Overview ¶
variadic demonstrates variable length arguments to Go functions
- A variable length argument can be specified with "..." before the type
- Example: "numbers ...int"
- Inside the function, the type becomes a slice ([]numbers)
In addition, we can also pass a slice with "..." to expand it as a argument list while calling the function. Example: sumAll(numbers...)
- The fmt.Printf and other formatting functions are the great examples for variadic functions.
Click to show internal directories.
Click to hide internal directories.