variadic

command
v0.0.0-...-a716749 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 25, 2023 License: Apache-2.0 Imports: 2 Imported by: 0

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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL