In Swift, it is possible to subclass a Generic class. Suppose that we have a Generic Container
class. There are two different ways to subclass it. In our first example, GenericContainer
subclasses the Container
class and stays as a Generic class. In our second example, SpecificContainer
subclasses Container
and becomes a Container
of Int
; therefore, it is not Generic anymore:
class Container<Item> { } // GenericContainer stays generic class GenericContainer<Item>: Container<Item> { } // SpecificContainer becomes a container of Int type class SpecificContainer: Container<Int> { }