You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
func Greeting(prefix string, who ...string) {
}
// classic parameter passing
Greeting("nobody")
Greeting("hello:", "Joe", "Anna", "Eileen")
s := []string{"James", "Jasmine"}
// ... parameter passing
Greeting("goodbye:", s...)
Greeting("goodbye:", append([]string{"Kevin"},s...)...) // work but is not really convenient
Greeting("goodbye:", "Kevin", s...) // is not working but would be nice
basically the ... operator can represent an "unpacking operation" and the compiler can see that Greeting("goodbye:", "Kevin", s...) doesn't break the prefix string, who ...string signature.
I hope this is clear
I think this would not break backcompatibily and make things nicer when working with variadic function
The text was updated successfully, but these errors were encountered:
In the following code:
basically the
...
operator can represent an "unpacking operation" and the compiler can see thatGreeting("goodbye:", "Kevin", s...)
doesn't break theprefix string, who ...string
signature.I hope this is clear
I think this would not break backcompatibily and make things nicer when working with variadic function
The text was updated successfully, but these errors were encountered: