“и в Swift6” Ответ

и в Swift6

// A logical and in swift is "&&"
// A logical or in swift is "||"

//E.g.
if a > 0 && i == j || f < 3 {
    ...
}
Fancy Flatworm

=== В Swift

//Triple Equals check that both object's reference is same or not.

class TripleEqualsExample : Equatable {
    let value: Int
     

    init(value: Int) {
        self.value = value
    }

    static func == (lhs: TripleEqualsExample, rhs: TripleEqualsExample) -> Bool {
        return lhs.value == rhs.value
    }
}



let instances1 = TripleEqualsExample(value: 5)
let instances2 = TripleEqualsExample(value: 5)

let instances3 = instances1

if instances1 == instances2 {
  print("the two instances are equal!")
}


if instances1 === instances2 {
  //It does not enter here
} else {
  print("the two instances are not identical!")
}


if instances3 === instances1 {
  print("the two instances are identical!")
}
Developer101

Смотреть популярные ответы по языку

Смотреть другие языки программирования