新增一系列数组操作的工具函数 #12

Merged
zhangdeman merged 8 commits from feature/arr_util into master 2025-12-04 10:49:44 +08:00
2cbffbd883 feat: 过滤列表数据方法
白茶清欢
2025-11-25 11:55:58 +08:00
Commit 3 of 8
Show all commits
+11
View File
@@ -26,3 +26,14 @@ func ExtractField[FieldValue any, Value any](dataList []Value, fieldValue func(i
}
return res
}
// Filter 过滤列表数据
func Filter[Value any](dataList []Value, filterValue func(item Value) bool) []Value {
res := make([]Value, 0)
for _, item := range dataList {
if filterValue(item) {
res = append(res, item)
}
}
return res
}
Reference in new issue
Block a user
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.