3 ms·
Check it once and type cast it before passing it down the call stack. If you need a polymorphic type all the way down then model it using structs and interfaces
by janderland 3y ago
Check it once and type cast it before passing it down the call stack. If you need a polymorphic type all the way down then model it using structs and interfaces so that the required operations are always available as methods.
It’s the same as other languages which lack optionals/narrowing: C/C++, Java, etc.
- leosanchez 3y agoC++ and Java both have some form of Optional btw.
- coldtea 3y agoYes, but in both it's not really mainstream.
- wrcwill 3y agosorry, type cast it to what? Say i have `*Thing`. Are you saying i should cast it to a `Thing`? That is what I was doing initially (im fine with copies), but then you can't call functions that mutate.