initial commit
This commit is contained in:
commit
493ce92e02
62 changed files with 1213 additions and 0 deletions
BIN
variadic-functions/vfunc
Executable file
BIN
variadic-functions/vfunc
Executable file
Binary file not shown.
20
variadic-functions/vfunc.go
Normal file
20
variadic-functions/vfunc.go
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
package main
|
||||
|
||||
import "fmt"
|
||||
|
||||
// below is a func that takes in an arbitrary number of ints as args
|
||||
func sum(nums ...int) {
|
||||
fmt.Print(nums, " ")
|
||||
total := 0
|
||||
for _, num := range nums {
|
||||
total += num
|
||||
}
|
||||
fmt.Println(total)
|
||||
}
|
||||
|
||||
func main(){
|
||||
sum(1,2)
|
||||
sum(1,2,3)
|
||||
nums := []int{1,2,3,4}
|
||||
sum(nums...)
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue