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> { }