mirror of
https://github.com/duke-git/lancet.git
synced 2026-02-11 08:12:26 +08:00
feat: add example for FindBy chore: reduce code duplication
This commit is contained in:
@@ -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"}}}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user