Declaring new convenience initializers with extensions
So far, we have always worked with one specific type of initializer for all the classes: designated and initializers. These are the primary initializers for a class in Swift, and they make sure that all the properties are initialized. In fact, every class must have at least one designated initializer. However, it is important to note that a class can satisfy this requirement by inheriting a designated initializer from its superclass.
There is another type of initializer known as convenience initializer that acts as a secondary initializer and always ends up calling a designated initializer. Convenience initializers are optional, so any class can declare one or more convenience initializers to provide initializers that cover specific use cases or more convenient shortcuts to create instances of a class.
Now, imagine that we cannot access the code for the previously declared Point3D
class. We are working on an app, and we discover too many...