Skip to content

Comment on Access Control in Swiftparent

Comments

The default "internal" access mode is similar to "protected". It's less granular, but that's to be expected since Swift does not (yet?) allow partitioning of a single app or library into different namespaces.

"internal" offers access to all in the module, not just subclasses.

"protected" would allow you to modify a member of a class when you inherit from it, whether it is in the same module or not.

using "internal" or "public" with a comment saying "please only use this when you subclass" the class is not as neat and tidy.

internel looks more like the default package scope in Java

Ah, shoot, you're right. That's what I was thinking about. It's been a long while since I actively used Java.

AboutSource Built by g1lg1l

Hackerly is an independent reader for Hacker News, built on the public HN API. Not affiliated with Y Combinator.