Created
March 15, 2019 04:04
-
-
Save abhimuralidharan/0c431cd0007cb915296e62909c85cfbe to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class A{ | |
class func classFunction(){ | |
} | |
static func staticFunction(){ | |
} | |
class func classFunctionToBeMakeFinalInImmediateSubclass(){ | |
} | |
} | |
class B: A { | |
override class func classFunction(){ | |
} | |
//Compile Error. Class method overrides a 'final' class method | |
override static func staticFunction(){ | |
} | |
//Lets avoid the function called 'classFunctionToBeMakeFinalInImmediateSubclass' being overriden by subclasses | |
/* First way of doing it | |
override static func classFunctionToBeMakeFinalInImmediateSubclass(){ | |
} | |
*/ | |
// Second way of doing the same | |
override final class func classFunctionToBeMakeFinalInImmediateSubclass(){ | |
} | |
//To use static or final class is choice of style. | |
//As mipadi suggests I would use. static at super class. and final class to cut off further overrides by a subclass | |
} | |
class C: B{ | |
//Compile Error. Class method overrides a 'final' class method | |
override static func classFunctionToBeMakeFinalInImmediateSubclass(){ | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment