I am trying to define Equatable using Swift structs. I am getting an error on the line func ==
saying Operators are only allowed at global scope
.
struct ShoppingList {
var shoppingListId :NSNumber
var title :String
init(title :String) {
self.title = title
self.shoppingListId = NSNumber(integer: 0)
}
}
extension ShoppingList {
public func ==(lhs :ShoppingList, rhs :ShoppingList) -> Bool {
return lhs.title == rhs.title
}
}
What am I missing?