How the parameter s
accepts an infinite number of arguments in a program where multiple strings arguments are passed.
Output
[]
[red blue]
[red blue green]
[red blue green yellow]
CodePudding user response:
I hope this helps:
func main() {
variadicExample()
variadicExample("red", "blue")
variadicExample("red", "blue", "green")
variadicExample("red", "blue", "green", "yellow")
}
func variadicExample(s ...string) {
fmt.Println(s)
}