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

doc: add go playground demo

This commit is contained in:
dudaodong
2024-03-06 15:28:55 +08:00
parent 1b31014f81
commit a6eaaef563
11 changed files with 127 additions and 26 deletions

View File

@@ -1173,7 +1173,7 @@ func AppendIfAbsent[T comparable](slice []T, item T) []T {
// SetToDefaultIf sets elements to their default value if they match the given predicate.
// It retains the positions of the elements in the slice.
// It returns slice of T and the count of modified slice items
// Play: todo
// Play: https://go.dev/play/p/9AXGlPRC0-A
func SetToDefaultIf[T any](slice []T, predicate func(T) bool) ([]T, int) {
var count int
for i := 0; i < len(slice); i++ {