reflection goes out of the window

This commit is contained in:
2019-11-10 01:24:45 +03:00
parent bc00262ead
commit f442dc6921
16 changed files with 87 additions and 63 deletions

View File

@ -4,6 +4,18 @@ import (
"reflect"
)
func IntInSlice(needle int, haystack[]int) (exists bool, index int) {
exists = false
index = -1
for i := 0; i < len(haystack); i++ {
if haystack[i] == needle {
return true, i
}
}
return exists, index
}
//left here for historical reasons
func InArray(val interface{}, array interface{}) (exists bool, index int) {
exists = false
index = -1
@ -21,4 +33,4 @@ func InArray(val interface{}, array interface{}) (exists bool, index int) {
}
}
return
}
}