On Sat, Feb 27, 2021 at 7:03 PM Deiter <hwaterf...@gmail.com> wrote: > > Go: go1.15.8 darwin/amd64 > OS: MacOS 11.2.1 > > The program here includes a function with variadic arguments: > func outputStrings(strings …string) > > Individual strings can be passed specifically: > outputStrings("foo", "bar") > > You can also use an ellipses to covert the content of an array to the > individual arguments: > > myStrings := []string{"foo", "bar"} > outputStrings(myStrings...) > > I expected that this would work as well: > outputStrings("foo", "bar", myStrings...) > > But it leads to: > > # variadic > ./variadic.go:17:15: too many arguments in call to outputStrings > have (string, string, []string...) > want (...string) > > The error message is clear, and easily worked around, so my question isn’t so > much why the error occurred, by rather should it have occurred? It seems to > me that the format of the function call make it clear and unambiguous to the > compiler what’s being passed.
This is https://golang.org/issue/18605. Ian -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/golang-nuts/CAOyqgcXbNO4Mo7S0-6CTm_QBeh8oh59o8G1908Bu4x9iCU6fSQ%40mail.gmail.com.