Navigation Menu

Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

variadic parameter not work well #27795

Closed
archever opened this issue Sep 21, 2018 · 1 comment
Closed

variadic parameter not work well #27795

archever opened this issue Sep 21, 2018 · 1 comment

Comments

@archever
Copy link

What version of Go are you using (go version)?

go1.10.3

What operating system and processor architecture are you using (go env)?

the same to macbookpro2015

What did you do?

https://play.golang.org/p/tyV3T-pkUy6

func test(i ...interface{}){}

a := []int{1,2,3}
test(a...)
// cannot use a (type []int) as type []interface {} in argument to test

why it can't be complied? a... is not equal to a[0], a[1], a[2] ???

What did you expect to see?

i suppose that ellipsis operator really split the slice and pass to the function as variadic parameter.
so make code like above success to be complied

@robpike
Copy link
Contributor

robpike commented Sep 21, 2018

This is a variant of the topic explained here: https://golang.org/doc/faq#convert_slice_of_interface

@robpike robpike closed this as completed Sep 21, 2018
@golang golang locked and limited conversation to collaborators Sep 21, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants