Skip to content

Instantly share code, notes, and snippets.

@shimastripe
Created August 29, 2022 04:12
Show Gist options
  • Save shimastripe/06a0e472c7200086adc0095f1cb91080 to your computer and use it in GitHub Desktop.
Save shimastripe/06a0e472c7200086adc0095f1cb91080 to your computer and use it in GitHub Desktop.
Struct の fileprivate / private の違い
struct Hoge {
fileprivate var hoge = 0
}
struct Fuga {
private var fuga = 0
}
var hoge = Hoge()
hoge.hoge = 2
print(hoge.hoge)
// # => 2
var fuga = Fuga()
fuga.fuga = 2
// Compile error: 'fuga' is inaccessible due to 'private' protection level
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment