aboutsummaryrefslogtreecommitdiff
path: root/example_each_test.go
blob: 211494a5e1ed626b7038b3dac1649a3c0afac897 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
package collection

import "fmt"

func ExampleEach() {
	collection := []int{1, 2, 3, 4, 5, 6}
	Each(collection, func(v int, idx int) {
		fmt.Printf("Element %d: %d\n", idx, v)
	})
}

func ExampleEachSync() {
	collection := []int{1, 2, 3, 4, 5, 6}
	EachSync(collection, func(v int, idx int) {
		fmt.Printf("Element %d: %d\n", idx, v)
	})
}