[swift-users] private vs. fileprivate on global declaration in Swift3?
fritza at manoverboard.org
Wed Sep 28 11:52:45 CDT 2016
On 28 Sep 2016, at 9:29 AM, Dave Reed via swift-users <swift-users at swift.org> wrote:
> They aren't identical. Here's a good explanation:
> http://useyourloaf.com/blog/swift-3-access-controls/ <http://useyourloaf.com/blog/swift-3-access-controls/>
Useful, but the OP asks about “global” symbols, which the examples show means “top-level.” The two have identical scope, and structures within the file are nested in the top level; they have access to its private symbols. (Verified in Xcode 8.)
If you’re collaborating with people who care, follow their coding standard. Otherwise it’s a matter of preference. Strive for the serenity to know that not everything needs a “best practice.”
(Hold a meeting. Write “SQL” on a whiteboard, presentation slide, or poster. Ask each person in the room to pronounce it. Be indifferent.)
Me, I’d go with “private,” just because it’s an English word. I can see an argument for using “fileprivate” to avoid precisely this kind of confusion.
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the swift-users