Having placed instances of a class into an array of another class I would like to remove the entire instance but because they all have the same name I cannot, but I would like to use a member called name.
var mammals: Creatures = Creatures(alive: true, safe: [sanctuary], injured: [hospital]) sanctuary: [Animals] = [goat, lion, parrot] let goat = Animals(name: "Terry", age: 13, legs: 4) let lion = Animals(name: "Benjamin", age: 5, legs: 4) let parrot = Animals(name: "Berty", age: 2, legs: 2)
When I check the sanctuary array through the mammals class member the elements displays with only their class name e.g. [Animals, Animals, Animals]. How do remove an element, I have tried using the where function from removeAll(where:) but it will not accept any of the instance members?
I suppose I am not doing it right?