[swift-users] override-like keyword for default implementations
    Johannes Weiss 
    johannesweiss at apple.com
       
    Tue May 16 10:53:39 CDT 2017
    
    
  
Hi swift-users,
Is there anything like the `override` keyword for making sure that default implementations in protocols are not adding a new function?
An example would be the following:
    protocol FooProto {
        func foo()
    }
    
    extension FooProto {
        func foo() { /* <-- can I mark this as being a default implementation */
            print("foo default")
        }
    }
Right now, there's a `func foo()` default implementation for `FooProto` but if later of `foo` gets refactored to `bar`, we lose the default implementation which can lead to problems.
Is there anything in Swift (like the `override` keyword) that allows me to say this is a default implementation and not a new method?
Thanks,
  Johannes
    
    
More information about the swift-users
mailing list