From 9cd6b0fca87679e570fbdd4942e3068feb3439fa Mon Sep 17 00:00:00 2001 From: Alexander Kiryukhin Date: Thu, 7 Apr 2022 21:36:40 +0300 Subject: initial --- example_map_test.go | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 example_map_test.go (limited to 'example_map_test.go') diff --git a/example_map_test.go b/example_map_test.go new file mode 100644 index 0000000..5ec879f --- /dev/null +++ b/example_map_test.go @@ -0,0 +1,26 @@ +package collection + +import ( + "fmt" + "strings" +) + +func ExampleMap() { + collection := []int{1, 2, 3, 4, 5} + cb := func(v int, idx int) string { + return fmt.Sprintf("[%d]", v) + } + result := Map(collection, cb) + fmt.Println(strings.Join(result, "_")) + // Output: [1]_[2]_[3]_[4]_[5] +} + +func ExampleMapSync() { + collection := []int{1, 2, 3, 4, 5} + cb := func(v int, idx int) string { + return fmt.Sprintf("[%d]", v) + } + result := MapSync(collection, cb) + fmt.Println(strings.Join(result, "_")) + // Output: [1]_[2]_[3]_[4]_[5] +} -- cgit v1.2.3