Erick has created a function indexOf(). It returns the index of a specific element in a slice of strings:
func indexOf(s []string, e string) int {
for i, v := range s {
if v == e {
return i
}
}
return -1
}
You have suggested Erick make indexOf() a generic function instead, so it can work with slices of int and float64 data types too. However, Erick doesn't know the most basic details about generics!
Can you help Erick write the entire generic implementation of the indexOf() function below? Take notice that to properly solve this task you must not change any code within the main function!