Open sindresorhus opened 2 years ago
There's no way to prevent it today, but maybe when Swift supports macros or constant expressions.
I have seen many users do:
static let interval = Key<Double?>("interval", default: nil)
The default parameter is moot in this case.
default
Or even worse:
static let interval = Key<Double?>("interval", default: 4)
Which has the incorrect behavior by never allowing the value to be set to nil. (The correct solution to this is #54)
nil
I wonder if we could use a macro to detect this and issue a warning.
There's no way to prevent it today, but maybe when Swift supports macros or constant expressions.
I have seen many users do:
The
default
parameter is moot in this case.Or even worse:
Which has the incorrect behavior by never allowing the value to be set to
nil
. (The correct solution to this is #54)