v0.0.425 ArrAppend
All checks were successful
Build Docker and Deploy / Run goext test-suite (push) Successful in 2m25s

This commit is contained in:
2024-03-30 14:24:53 +01:00
parent 9491b72b8d
commit 36b71dfaf3
2 changed files with 11 additions and 2 deletions

View File

@@ -453,6 +453,15 @@ func ArrConcat[T any](arr ...[]T) []T {
return r
}
// ArrAppend works similar to append(x, y, z) - but doe snot touch the old array and creates a new one
func ArrAppend[T any](arr []T, add ...T) []T {
r := ArrCopy(arr)
for _, v := range add {
r = append(r, v)
}
return r
}
// ArrCopy does a shallow copy of the 'in' array
func ArrCopy[T any](in []T) []T {
out := make([]T, len(in))