aboutsummaryrefslogtreecommitdiff
path: root/example_each_test.go
diff options
context:
space:
mode:
authorAlexander Kiryukhin <a.kiryukhin@mail.ru>2022-04-07 21:36:40 +0300
committerAlexander Kiryukhin <a.kiryukhin@mail.ru>2022-04-07 21:36:40 +0300
commit9cd6b0fca87679e570fbdd4942e3068feb3439fa (patch)
tree557bf877d71854480f4171e9dd324cebb5606056 /example_each_test.go
initial
Diffstat (limited to 'example_each_test.go')
-rw-r--r--example_each_test.go17
1 files changed, 17 insertions, 0 deletions
diff --git a/example_each_test.go b/example_each_test.go
new file mode 100644
index 0000000..211494a
--- /dev/null
+++ b/example_each_test.go
@@ -0,0 +1,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)
+ })
+}