Advertisement
Guest User

Untitled

a guest
Jun 17th, 2019
50
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.35 KB | None | 0 0
  1. func in(list interface{}, val interface{}) bool {
  2.  
  3. listVal := reflect.ValueOf(list)
  4. //need to find a way instead of hardcoding datatype get the data type accordingly
  5. //from list to convert it easily
  6. actualList := listVal.Interface().([]int)
  7. for i := 0; i < len(actualList); i++ {
  8.  
  9. if actualList[i] == val {
  10. return true
  11. }
  12. }
  13. return false
  14. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement