[swift-evolution] Overrides in class extensions

Rudolf Adamkovič salutis at me.com
Fri Jul 1 07:00:48 CDT 2016

Hi there!

the Swift book says:

> Extensions in Swift can:
> • Add computed instance properties and computed type properties
> • Define instance methods and type methods
> • Provide new initializers
> • Define subscripts
> • Define and use new nested types
> • Make an existing type conform to a protocol
> Extensions can add new functionality to a type, but they cannot override existing functionality.

However, in practice we can override methods in class extensions:

class ViewController: UIViewController {}

extension ViewController {
    override func viewDidLoad() {}

This seems to be incompatible with what the book claims:

> … cannot override existing functionality ...

So, my questions are:

• Why are overrides allowed in class extensions?
• Am I reading the book wrong? :)

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-evolution/attachments/20160701/671060b6/attachment.html>

More information about the swift-evolution mailing list