What is the difference between == and === operators in Swift? Detailed explanation for beginners
Hello everyone! I just started learning Swift and encountered some confusion. In the code I see two operators: == and ===. At first glance they do the same thing — compare values. But I noticed that the compiler sometimes complains when I try to use them incorrectly.\n\nHere's an example that confuses me:\n\n```swift\nclass Person {\n var name: String\n init(name: String) {\n self.name = name\n }\n}\n\nlet person1 = Person(name: "Alice")\nlet person2 = Person(name: "Alice")\nlet person3 = person1\n\nprint(person1 == person2) // Error: binary operator '==' cannot be applied to operands of type 'Person'\nprint(person1 === person2) // false\nprint(person1 === person3) // true\n```\n\nWhy does `==` not work at all for my class, while `===` works but gives different results?