Skip to content

Instantly share code, notes, and snippets.

@akshitzaveri
Created May 26, 2020 18:08
Show Gist options
  • Save akshitzaveri/0630ade93c270eb185d329fe27bc2b2d to your computer and use it in GitHub Desktop.
Save akshitzaveri/0630ade93c270eb185d329fe27bc2b2d to your computer and use it in GitHub Desktop.
// 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