1
0
mirror of https://github.com/duke-git/lancet.git synced 2026-02-11 08:12:26 +08:00

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:
燕归来
2023-04-17 20:11:56 +08:00
committed by GitHub
parent 47bdd6718a
commit 14bc08c6d6
3 changed files with 60 additions and 14 deletions

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"}}}