Reputation: 41490
In Swift Programming Language guide, it says:
“The default initializer has the same access level as the type it initializes.”
Excerpt From: Apple Inc. “The Swift Programming Language.” iBooks. https://itun.es/us/jEUH0.l
and then it says:
“For a type that is defined as public, the default initializer is considered internal. If you want a public type to be initializable with a no-argument initializer when used in another module, you must provide a public no-argument initializer yourself as part of the type’s definition.”
Excerpt From: Apple Inc. “The Swift Programming Language.” iBooks. https://itun.es/us/jEUH0.l
Isn't the second statement contradictory with the first?
Upvotes: 7
Views: 261
Reputation: 1120
Nope.
The second statement is just a complementary note on the first one.
I think it wants to say that the public-access type is a special case: the access level of the default initializer for public-access case is internal. If one want to provide a public-access default initializer, then he needs to do it explicitly.
Correct me if I'm wrong.
Upvotes: 1