v0.0.563 Add 'ArrContains' alias for 'InArray'
All checks were successful
Build Docker and Deploy / Run goext test-suite (push) Successful in 2m7s
All checks were successful
Build Docker and Deploy / Run goext test-suite (push) Successful in 2m7s
This commit is contained in:
parent
4d606d3131
commit
4832aa9d6c
@ -1,5 +1,5 @@
|
|||||||
package goext
|
package goext
|
||||||
|
|
||||||
const GoextVersion = "0.0.562"
|
const GoextVersion = "0.0.563"
|
||||||
|
|
||||||
const GoextVersionTimestamp = "2025-01-29T11:24:20+0100"
|
const GoextVersionTimestamp = "2025-01-31T21:16:42+0100"
|
||||||
|
@ -24,6 +24,7 @@ func Range[T IntegerConstraint](start T, end T) []T {
|
|||||||
return r
|
return r
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ForceArray ensures that the given array is not nil (nil will be converted to empty)
|
||||||
func ForceArray[T any](v []T) []T {
|
func ForceArray[T any](v []T) []T {
|
||||||
if v == nil {
|
if v == nil {
|
||||||
return make([]T, 0)
|
return make([]T, 0)
|
||||||
@ -47,6 +48,16 @@ func InArray[T comparable](needle T, haystack []T) bool {
|
|||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ArrContains checks if the value is contained in the array (same as InArray, but odther name for better findability)
|
||||||
|
func ArrContains[T comparable](haystack []T, needle T) bool {
|
||||||
|
for _, v := range haystack {
|
||||||
|
if v == needle {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
func ArrUnique[T comparable](array []T) []T {
|
func ArrUnique[T comparable](array []T) []T {
|
||||||
m := make(map[T]bool, len(array))
|
m := make(map[T]bool, len(array))
|
||||||
for _, v := range array {
|
for _, v := range array {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user