Created
September 21, 2018 10:44
-
-
Save archever/c585a67e54e36ae9697dc66a76d2b637 to your computer and use it in GitHub Desktop.
golang ... 可变参数并不是展开传递的
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import "log" | |
func test(data ...interface{}) { | |
for _, i := range data { | |
log.Printf("data: %v", i) | |
} | |
} | |
func main() { | |
a := []int{1, 2, 3, 4} | |
// cannot use a (type []int) as type []interface {} in argument to test | |
test(a...) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment