Difference between == and ===

In swift 3 and above

=== (or !==)

  • Checks if the values are identical (both point to the same memory address).
  • Comparing reference types.
  • Like == in Obj-C (pointer equality).

== (or !=)

  • Checks if the values are the same.
  • Comparing value types.
  • Like the default isEqual: in Obj-C behavior.

Here I compare three instances (class is a reference type)



https://stackoverflow.com/questions/24002819/difference-between-and

猜你喜欢

转载自www.cnblogs.com/feng9exe/p/9104135.html