You can add an Array Extension that does exactly what you want, i.e:
extension Array {
func indexOf(x:T) -> Int? {
for i in 0..self.count {
if self[i] as T == x {
return i
}
}
return nil
}
}
Which now lets you use .indexOf()
on all Swift arrays, e.g:
["Jason", "Charles", "David"].indexOf("Jason") //0