Private vs. fileprivate when declaring global variables / constants in Swift3?

Should I use private or fileprivate to declare global variables / constants in Swift 3? eg.

fileprivate let a = 1
fileprivate class SomeClass {
    fileprivate b = 0
}

Or

private let a = 1
private class someClass {
    fileprivate b = 0
}
+4
source share
1 answer

At the file level, it really doesn’t matter if you use privateout fileprivate, access control will be the same, for example, the constants defined in this way will be used only in this file.

The same can be said for other modifiers, in some cases the internal and private ones become the same, for example. the same single file module.

fileprivate, → .

swift ( swift 4), , fileprivate private ,

+3

Source: https://habr.com/ru/post/1656053/


All Articles