Skip to content

Instantly share code, notes, and snippets.

@williamhjcho
Created February 1, 2018 23:56
Show Gist options
  • Save williamhjcho/b48bf4504b33c039bf394f2493c03f2a to your computer and use it in GitHub Desktop.
Save williamhjcho/b48bf4504b33c039bf394f2493c03f2a to your computer and use it in GitHub Desktop.
struct Test {
func a() {
b()
c() // can access if in same file (fileprivate)
d() // same (private)
e() // same (private extension)
f() // same (private extension and private method)
}
}
extension Test {
func b() {
f() // can access even if it's extension is also private
}
fileprivate func c() {}
private func d() {}
}
private extension Test {
func e() {
d() // can access while it's still private
}
private func f() {}
// gives a warning when defining fileprivate func within private extension
//fileprivate func g() {}
}
// In another file
let test = Test()
test.a()
test.b()
//test.c() // can't access
//test.d() // can't access
test.e()
//test.f() // can't access
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment