struct Person {
var name: String
var age: String
}
//To make that Equatable you need to add the Equatable conformance. If don’t want to check all properties for equality, or if any of your properties are not also Equatable, then you need to write your own == function like this:
extension Person: Equatable {
static func ==(lhs: Person, rhs: Person) -> Bool {
return lhs.name == rhs.name && lhs.age == rhs.age
}
}
let Person1 = Person(name: "Deepak Rawat", age: "26")
let Person2 = Person(name: "Pratik Rawat", age: "26")
if(Person1==Person2)
{
print("true")
}
else
{
print("false")
}
To embed this project on your website, copy the following code and paste it into your website's HTML: