13 ms·
Disagree. Types are both for the compiler, as well as for the developer. Maybe types are implicit documentation telling the developer that it is meaningful in
by gf000 4mo ago
Disagree.
Types are both for the compiler, as well as for the developer. Maybe types are implicit documentation telling the developer that it is meaningful in the application that this field can have a None state.
That's a huge code smell to ever set null to an Optional/Maybe and code reviews, linters, nullness analyzers all should/will flag such.
Like I have never ever had an NPE from an Optional being null. Sure, complete null safety would be better of course, but in this very instance it ain't buying you much.
- mrkeen 4mo agoThis is what your choices are with regard to communicating to the compiler and other developers. Use a regular class to signal that you may or may not have a value. Wrap it in an optional to signal that you may or may not have a value. See the problem?