feat: add FindBy that a result will be without unrefrence #88 (#90)

feat: add example for FindBy

chore: reduce code duplication
This commit is contained in:
燕归来 authored and GitHub committed 2023-04-17 20:11:56 +08:00
1 parent 47bdd6718a
commit 14bc08c6d6
3 files changed
+60 -14

No files matched your search

+17
View File
@@ -341,6 +341,23 @@ func ExampleFindLast() {
// true
}
func ExampleFindBy() {
nums := []int{1, 2, 3, 4, 5}
isEven := func(i, num int) bool {
return num%2 == 0
}
result, ok := FindBy(nums, isEven)
fmt.Println(result)
fmt.Println(ok)
// Output:
// 2
// true
}
func ExampleFlatten() {
arrs := [][][]string{{{"a", "b"}}, {{"c", "d"}}}