The filter method is a really powerful tool for filtering by single or multiple conditions, but is there a way to filter by conditions of arrays?
class Car with properties : model, color, engineStatus.
carsis an array with few cars
By one condition would look like:
let currModel = `Opel`
let filterdObject = cars.filter { $0.model == currModel }
By two or more conditions would look like:
let currModel = `Opel`
let currColor = `Green`
let filterdObject = cars.filter { $0.model == currModel || $0.color == currColor }
My question is it how could I filter by an array like:
An array has ,e.g., two colors blue and green. I would like to filter cars by these colors. My point is to get a formula for n-conditions.
cars.filter {arrayOfColors(contains:$0.color)}?