After using this code from a tutorial that apparently worked before, isn't working now using swift 3 but I'm not sure why. The error shows on the line: if !contains(uniqueValues, value as T)
extension Array {
func unique<T: Equatable>() -> [T] {
var uniqueValues = [T]();
for value in self {
if !contains(uniqueValues, value as T) {
uniqueValues.append(value as! T);
}
}
return uniqueValues;
}
func first<T>(test:(T) -> Bool) -> T? {
for value in self {
if test(value as! T) {
return value as? T;
}
}
return nil;
}
}