feat: add FindLastBy function

This commit is contained in:
dudaodong committed 2023-04-17 20:17:26 +08:00
1 parent 14bc08c6d6
commit 52ea64bc33
3 files changed
+56

No files matched your search

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