O'Reilly logo

Swift Functional Programming - Second Edition by Dr. Fatih Nayebi

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Overriding

Swift permits a class or object to replace the implementation of a behavior/property that it has inherited. This process is called overriding. The override keyword is used to specify overridden methods in subclasses.

We can override an inherited instance or class property to provide our own custom/computed getters and setters or add property observers to enable the overriding property to observe when the underlying property value changes.

We can mark a property or behavior as final to prevent overriding it in subclasses.

Overriding brings a complication that needs to be handled. We need to ensure which version of the behavior/property an instance of the subclass should use: the one that is part of its own class (self) or the one ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required