[swift-users] private vs. fileprivate on global declaration in Swift3?

Nevin Brackett-Rozinsky nevin.brackettrozinsky at gmail.com
Wed Sep 28 11:18:00 CDT 2016


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.

Nevin



On Wed, Sep 28, 2016 at 12:14 PM, Marco S Hyman via swift-users <
swift-users at swift.org> wrote:

>
> > On Sep 28, 2016, at 8:04 AM, Jens Alfke via swift-users <
> swift-users at swift.org> wrote:
> >
> >
> >> On Sep 28, 2016, at 12:16 AM, Cao Jiannan via swift-users <
> swift-users at swift.org> wrote:
> >>
> >> I think the Swift team should tell us which is better.
> >
> > If one were better than the other, they wouldn’t both exist...
> >
> > It depends on whether you need to use those entities in other source
> files in the same module.
> > If you don’t, use fileprivate. If you do, use private.
>
> private is *more* restrictive than fileprivate.  If you need to use the
> entities in other source files in the same module you want internal, not
> private.
> _______________________________________________
> swift-users mailing list
> swift-users at swift.org
> https://lists.swift.org/mailman/listinfo/swift-users
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-users/attachments/20160928/1c61d2e2/attachment.html>


More information about the swift-users mailing list