Swift calling static methods: type(of: self) vs explicit class name
In swift, an instance func can't call a static/class func without prefixing the method call with the class name. OR you can use type(of: self) , e.g class Foo { static func doIt() { } func callIt() { Foo.doIt() // This works type(of: self).doIt() // Or this doIt() // This doesn't compile (unresolved identifier) } } My question is, what's the difference here? Is it just a matter of coding style, or is there some difference e.g. static or dynamic dispatch going on? If it is just coding style, what's the preferred style? Hamish There are two main differences. 1. The value of self inside the