Created
May 26, 2020 18:08
-
-
Save akshitzaveri/0630ade93c270eb185d329fe27bc2b2d 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
// Our Original class | |
class Example { | |
// Original function | |
static func start() { | |
print("Start") | |
} | |
} | |
// Subclassing | |
class ExampleSubclass: Example { | |
// Throw an error "Cannot override static method" | |
override static func start() { | |
print("Overridden Start") | |
} | |
} | |
Example.start() // This will print "Start" in the console. | |
ExampleSubclass.start() // Compiler error - Ambiguous use of 'start()'. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment