I have this problem and I'm newer to Swift. I have tried looking around on the internet and found stuff which looked right but for some reason I can't use it. This is the snippet I am using:
/** This struct is meant to hold all of the information taken from the firebase database */
struct Service {
var name: String
var description: String
var hours: String
var type: String
var estimated_payment: String
var ge_min_payment: String
var hourly_rate: String
var income_category: String
var part_cost: String
var part_markup: String
var standard_price: String
var task_number: String
var ttsp_price: String
var ttsp_savings: String
var agreement_discount: String
var annual_part_increase: String
}
// ...
/** cartArray contains all the objects currently in the cart for checkout */
var cartArray: [Service] = []
// ....
/**
* isInCart
*
* a boolean function which checks to see if a specific service object is in the array
*/
func isInCart(service: Service) -> Bool {
var contained = self.cartArray.contains(service)
return contained ? true : false;
}
When I try to compile this project, this is the error I am receiving:
I'm a little confused on what is wrong with it. Could someone help?