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)
| 244 | // |
| 245 | // hasValue := dgo.Contains(numbers, 42) |
| 246 | func 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 | // |
no outgoing calls