neko/pkg/utils/array.go
Miroslav Šedivý babddacbf3
Go generics and changes in v1.18 (#5)
* ArrayIn to use generics.

* interface{} -> any.
2022-07-28 12:20:20 +02:00

15 lines
213 B
Go

package utils
func ArrayIn[T comparable](val T, array []T) (exists bool, index int) {
exists, index = false, -1
for i, a := range array {
if a == val {
exists, index = true, i
return
}
}
return
}