class Animal {} class Cat : Animal {} class Dog : Animal {} let animals: [Animal] = [Cat(), Cat(), Dog()] print(Set(animals.map { type(of: $0) }))