April 2017
Intermediate to advanced
316 pages
9h 33m
English
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> { }
Read now
Unlock full access