You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Sometimes SomeType is supposed to be private. But if we declare outside of class/struct declaration, it is default to public scope.
To mark it private, we can use private (for inside this class or it's extension in Swift 4) or fileprivate (inside this class only); but that is not the point here.
So if we declare as nested. It means SomeClassownsSomeType enum, so callers need explicit call SomeClass.SomeType.
// Not PreferredenumSomeType{// exposedcase foo, bar, baz, unknown
}classSomeClass{// MARK: PROPERTIESprivatevartype=SomeType.unknown
}
Note to self, don't do outer scope enum/struct declaration, try nested instead.
Be friend with Swift's name-spacing (nested) feature to better code management.
Sometimes
SomeType
is supposed to be private. But if we declare outside of class/struct declaration, it is default to public scope.To mark it private, we can use
private
(for inside this class or it's extension in Swift 4) orfileprivate
(inside this class only); but that is not the point here.So if we declare as nested. It means
SomeClass
ownsSomeType
enum, so callers need explicit callSomeClass.SomeType
.Reference: #46
🚀 👍
The text was updated successfully, but these errors were encountered: