3 ms·
> Option types are way better and always do what you expect. No, I can implement the exact same weird functions with option types, with signatures sum: Array<
by zodiac 6y ago
> Option types are way better and always do what you expect.
No, I can implement the exact same weird functions with option types, with signatures
sum: Array<Int> -> Optional<Int>
count_elements: Array<Int> -> Int
FWIW, I personally prefer both functions to not return Optionals, but the point is that the mere presence of Option types in your type system (and the absence of null pointers) doesn't magically eliminate bad library design
- cerved 6y agoimho, aggregation on []<x> should return option<x> unless aggregation on an empty list is exceptional in which case it may throw