swift 可等于协议的数组扩展

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了swift 可等于协议的数组扩展相关的知识,希望对你有一定的参考价值。

extension Array: Equatable where Element: Equatable {
  
  static func ==(lhs: Array<Element>, rhs: Array<Element>) -> Bool {
    let count = lhs.count
    if count != rhs.count { return false }
    for x in 0..<count {
      if lhs[x] != rhs[x] { return false }
    }
    return true
  }
}

以上是关于swift 可等于协议的数组扩展的主要内容,如果未能解决你的问题,请参考以下文章