Skip to content

Instantly share code, notes, and snippets.

@hygull
Created December 9, 2016 01:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hygull/d308d375b4d2a19bd087efc24d60b432 to your computer and use it in GitHub Desktop.
Save hygull/d308d375b4d2a19bd087efc24d60b432 to your computer and use it in GitHub Desktop.
Variable number of arguments of any type created by hygull - https://repl.it/Eiky/6
package main
import "fmt"
func main() {
showAllParamsOfAnyTypes("Golang",2007,[]string{"Robert Griesemer","Rob Pike",
"Ken ThThompsson"})
showAllParamsOfIntType(12,34,45,67,45) //Passinng 5 parameters
showAllParamsOfIntType(23,45,75) //Passing 3 parameters
}
func showAllParamsOfAnyTypes(paramsList ...interface{}){
for _,param:= range paramsList{
fmt.Println(param)
}
i:=0
for i<len(paramsList){
fmt.Println(paramsList[i])
i+=1
}
fmt.Println() //For new line
}
func showAllParamsOfIntType(paramsList ...int){
for _,param:= range paramsList{
fmt.Print(param," ")
}
fmt.Println() //For new line
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment