Created
December 9, 2016 01:24
-
-
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
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 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