the required constructor seems confused

If you omit the explicitly initializer, it generates a memberwise initializer, init(middle:first:last:) (where middle happens to have a default value), but because middle is private, so is this initializer.

As the documentation says:

The default memberwise initializer for a structure type is considered private if any of the structure’s stored properties are private. Likewise, if any of the structure’s stored properties are file private, the initializer is file private. Otherwise, the initializer has an access level of internal.

If middle wasn’t marked as a variable that could be set (either by making it a constant with private let or setting only the setter to be private (with private(set) var, then only init(first:last:) would be created on your behalf.

CLICK HERE to find out more related problems solutions.

Leave a Comment

Your email address will not be published.

Scroll to Top