3 ms·
This works for those two types, but consider something slightly more general like an Either type with a Left and Right. You could just repeat the same think as
by treyd 2y ago
This works for those two types, but consider something slightly more general like an Either type with a Left and Right. You could just repeat the same think as Ok but for Left or Right, but then why pick one or the other? It becomes a footgun with more complex scenarios to always demand some default value. Also how it interacts with generics needs to be considered.
- chrismorgan 2y agoLook, Result defaulting to Ok is stupid too—it doesn’t have a sensible default value. But Go already has a problem with some of its zero values being stupid. I don’t think proper enums would make it any worse?
- stouset 2y agoI think this is a reasonable take. It might be a stupid decision, but it's at least consistently stupid.