Post

Replies

Boosts

Views

Activity

Why can't Protocols be nested in other Types?
We can nest classes, structs & enums:class TestClass { class OtherClass {} struct OtherStruct {} enum OtherEnum {} }Why can't we also nest protocols?class TestClass { protocol Delegate {} // error: Declaration is only valid at file scope }So far the workaround is to declare it at file scope using and use a typealias instead.The underscore prefix makes it clear that the global symbol name is not intended for direct use.class TestClass { typealias Delegate = _TestDelegate } protocol _TestDelegate {}Is this just not yet implemented or is there a reason for not supporting that at all?
34
1
15k
Sep ’22