Skip to main content
Journey Uncommon Logo
JourneyUncommon
hardSwiftmetatype and runtime metadataSingle-choice MCQ

Given `let a: Animal = Dog()` where `Dog: Animal`, why does `type(of: a)` return `Dog.self` rather than `Animal.self`?

class Animal {} class Dog: Animal {} let a: Animal = Dog() print(type(of: a) == Dog.self) print(type(of: a) == Animal.self)