Replacement for array's indexOf(_:) method in Swift 3

后端 未结 3 902
小蘑菇
小蘑菇 2021-02-01 03:20

In my project (written in Swift 3) I want to retrieve index of an element from array using indexOf(_:) method (existed in Swift 2.2), but I cannot find any replacem

3条回答
  •  旧巷少年郎
    2021-02-01 04:06

    This worked for me in Swift 3 without an extension:

    struct MyClass: Equatable {
        let title: String
    
        public static func ==(lhs: MyClass, rhs: MyClass) -> Bool {
            return lhs.title == rhs.title
        }
    }
    

提交回复
热议问题