Post not yet marked as solved
Post marked as unsolved with 34 replies, 13,254 views
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?