4 ms·
I like the way PHP does it, where the return type of a function can be Object, which does not allow null, or ?Object, which does allow null. Although I would pr
by asddubs 5y ago
I like the way PHP does it, where the return type of a function can be Object, which does not allow null, or ?Object, which does allow null. Although I would probably still consider using an Optional<Object> type if PHP had generics (of course you can still write an Optional-pattern using a mixed return type, but then you lose type guarantees), just so you cannot access the value at all without being reminded that you do need to check that type, even if you never look at the return type