Created
August 29, 2022 04:12
-
-
Save shimastripe/06a0e472c7200086adc0095f1cb91080 to your computer and use it in GitHub Desktop.
Struct の fileprivate / private の違い
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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