I have array of custom objects
var shopList = [String: [ShopItem]]()
Custom class
class ShopItem {
var id = ""
var name = ""
var quantity = 0.0
var price = 0.0
var category = ""
init(id: String, name: String, quantity: Double, price: Double, category: String) {
self.id = id
self.name = name
self.quantity = quantity
self.price = price
self.category = category
}
var uom: String {
return "шт."
}
var total: Double {
return quantity * price
}
}
What is right way to remove object from array? I tried to do it way below
extension ShopItem: Equatable {}
func ==(left: ShopItem, right: ShopItem) -> Bool {
return left.id == right.id
}
But as you see I got error :(