PROGRAM:
OUTPUT:
0 -> 10
1 -> 20
2 -> 30
0 -> 52
1 -> 43
2 -> 24
3 -> 78
4 -> 23
0 -> 1
1 -> 2
2 -> 3
3 -> 4
4 -> 5
5 -> 6
6 -> 7
7 -> 8
package main
import "fmt"
func main() {
myfunc(10, 20, 30)
fmt.Printf("\n")
myfunc(52, 43, 24, 78, 23)
fmt.Printf("\n")
vals := []int{1, 2, 3, 4, 5, 6, 7, 8}
myfunc(vals...)
}
func myfunc(args ...int) {
for ind, val := range args {
fmt.Println(ind, "->", val)
}
}
OUTPUT:
0 -> 10
1 -> 20
2 -> 30
0 -> 52
1 -> 43
2 -> 24
3 -> 78
4 -> 23
0 -> 1
1 -> 2
2 -> 3
3 -> 4
4 -> 5
5 -> 6
6 -> 7
7 -> 8
No comments:
Post a Comment