[swift-users] private vs. fileprivate on global declaration in Swift3?
milseman at apple.com
Thu Sep 29 15:15:21 CDT 2016
All access control modifiers have a degenerate case (roughly) equivalent to another one, and the typical wisdom for which to choose is to analyze your intent and perhaps future intent.
“fileprivate” and “private” are identical at global scope.
“internal” and “fileprivate” are identical in single-file modules.
“public” and “internal” are (well, roughly…) equivalent if you only have a single module.
> On Sep 29, 2016, at 1:30 AM, Quinn The Eskimo! via swift-users <swift-users at swift.org> wrote:
> On 28 Sep 2016, at 17:18, Nevin Brackett-Rozinsky via swift-users <swift-users at swift.org> wrote:
>> To answer the original question: at file scope the access modifiers `private` and `fileprivate` have exactly the same effect. It does not matter which of them you use there.
> Right, but that doesn’t tell you which one you /should/ use. Personally I’d probably go for `fileprivate` because it seems more explicit to me, but I’d be interested in hearing other opinions.
> Share and Enjoy
> Quinn "The Eskimo!" <http://www.apple.com/developer/>
> Apple Developer Relations, Developer Technical Support, Core OS/Hardware
> swift-users mailing list
> swift-users at swift.org
More information about the swift-users