4. Variadic
func concat(strs ...string) string {
final := ""
// strs is just a slice of strings
for i := 0; i < len(strs); i++ {
final += strs[i]
}
return final
}
func main() {
final := concat("Hello ", "there ", "friend!")
fmt.Println(final)
// Output: Hello there friend!
}func Println(a ...interface{}) (n int, err error)Spread Operator
Assignment
Solution
Go Variadic Functions
What Are Variadic Functions?
Key Concepts
Declaration Syntax
Inside the Function
Calling Variadic Functions
The Spread Operator (...)
...)Common Standard Library Examples
Your Solution Explained
Rules and Constraints
Summary
Concept
Syntax
Purpose