Created
January 3, 2018 15:36
-
-
Save khan-rizwan/4aa0e4d7cb4df8d6a86e139939577ef3 to your computer and use it in GitHub Desktop.
How to pass a slice as a variadic input?
This file contains 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 ( | |
"fmt" | |
) | |
func echo(strings []int) []interface{} { | |
ids := []interface{}{} | |
for _, s := range strings { | |
ids = append(ids, s) | |
} | |
return ids | |
} | |
func vardic(val ...interface{}){ | |
fmt.Println(val) | |
} | |
func main() { | |
i := []int{1,2,3} | |
fmt.Println("Hello",i) | |
vardic(echo(i)...) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment