Search code examples
swiftclassprotocols

A class name can be the same as a protocol name in Swift?


A class name can be the same as a protocol name in Swift? I want to implement a protocol that has the same name as another class.


Solution

  • A class name can only be the same as a protocol name if they are in different modules, or if the class is nested inside another type. Even then, it will probably be confusing.