1

As far as I know static funcs are statically dispatched and final class funcs are also statically dispatched (since final funcs cannot be overriden - just like static funcs). But then what exactly is the difference. Is there any at all?

angshuk nag
  • 451
  • 5
  • 11
  • 1
    Possible duplicate of [What is the difference between static func and class func in Swift?](https://stackoverflow.com/questions/25156377/what-is-the-difference-between-static-func-and-class-func-in-swift) – Papershine Sep 16 '18 at 05:20
  • no.. that is class func, not final class func :) – angshuk nag Sep 16 '18 at 05:34

1 Answers1

4

Just because a final class function can't be overridden doesn't mean it's statically dispatched. A final class function be override a superclass non-final class function. Such a method call must be dynamically dispatched.

static is merely an alias for final class. They behave the same:

class C1 { class func foo() {} }
class C2: C1 { override final class func foo() {} }
class C3: C1 { override static func foo() {} }
Alexander
  • 59,041
  • 12
  • 98
  • 151