MCPcopy
hub / github.com/MadAppGang/dingo / Contains

Function Contains

pkg/dgo/slice.go:246–253  ·  view source on GitHub ↗

Contains returns true if the slice contains the given value. Uses == for comparison, so T must be comparable. Example: hasValue := dgo.Contains(numbers, 42)

(slice []T, value T)

Source from the content-addressed store, hash-verified

244//
245// hasValue := dgo.Contains(numbers, 42)
246func Contains[T comparable](slice []T, value T) bool {
247 for _, v := range slice {
248 if v == value {
249 return true
250 }
251 }
252 return false
253}
254
255// Count returns the number of elements that satisfy the predicate.
256//

Callers 2

demonstrateSearchFunction · 0.92
TestContainsFunction · 0.85

Calls

no outgoing calls

Tested by 1

TestContainsFunction · 0.68