最后一条语句为什么失败与错误编译:Binary operator '==' cannot be applied to two '[[Simple]]’ operands,而且是有办法的方式来修改一个Simple结构或延长==运营商能够在嵌套阵列(或字典)进行平等检查?
var i1: [Int] = [1]
var i2: [Int] = [1]
i1 == i2 // -> true
var i3: [[Int]] = [[1], [2]]
var i4: [[Int]] = [[1], [2]]
i3 == i4 // -> true
struct Simple: Equatable, Hashable {
let message: String
var hashValue: Int {
return message.hashValue
}
}
func ==(lhs: Simple, rhs: Simple) -> Bool {
return lhs.message == rhs.message
}
var …Run Code Online (Sandbox Code Playgroud) swift ×1