Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR SWIFT

Swift Equatable Protocol

struct Employee: Hashable {
  var name: String
}

let obj1 = Employee(name: "Sabby")
let obj2 = Employee(name: "Smith")

// compare obj1 and obj2
if obj1 == obj2 {
    print("obj1 and obj2 are equal")
}
else {
    print("obj1 and obj2 are not equal")
}
 
PREVIOUS NEXT
Tagged: #Swift #Equatable #Protocol
ADD COMMENT
Topic
Name
2+4 =