Always default optionalsDefaultNil
to false
, despite Swift 5
#7
Labels
enhancement
New feature or request
optionalsDefaultNil
to false
, despite Swift 5
#7
Description
Swift provides non-public initializers that default optionals to
nil
. A design tenet of MemberwiseInit has been to strive to be a pure superset of Swift's memberwise initializer, and this approach has largely served it well.However, I'm convinced that MemberwiseInit should deviate from Swift 5 and always default
_optionalsDefaultNil
to false, regardless of access level.Swift's behavior is:
Int?
andOptional<Int>
(defaultednil
and not defaulted, respectively),MemberwiseInit can offer a more straightforward approach: Optionals should not default to
nil
unless explicitly specified by the developer.This has been debated at length on the forums:
The text was updated successfully, but these errors were encountered: