Finding the index/indices of an element in an array

Swift 3, macOS 10.12 class Food { var name: String = “” init(name: String){ self.name = name } } let chocolate = Food(name: “Chocolate”) let spinach = Food(name: “Spinach”) let greenTea = Food(name: “Green Tea”) let favouriteThings = [greenTea, chocolate, greenTea, spinach, greenTea] If your element conforms to the equatable protocol or inherits from NSObject, […]