Swift Array.insert generics

前端 未结 5 1667
盖世英雄少女心
盖世英雄少女心 2020-12-07 03:02
func getIndex(valueToFind: T) -> Int? {...}

mutating func replaceObjectWithObject(obj1: T, obj2: T) {
    if let index =          


        
5条回答
  •  野趣味
    野趣味 (楼主)
    2020-12-07 03:20

    How did you declare your Array extension? The problem is that your generic functions require arguments of type Equatable, but when you declared the array, you specified a specific implementation of an Equatable class, like String. A T is not a String without a cast.

提交回复
热议问题