3 ms·
>> Solution: Use a NullObject or Optional type instead of ever passing a null. An empty collection is a great alternative. That doesn't work if you are buildin
by csomar 8y ago
>> Solution: Use a NullObject or Optional type instead of ever passing a null. An empty collection is a great alternative.
That doesn't work if you are building a library, or working with other software developers. The alternative is to have a strictly typed language that forces the user to pick the type of the variable.
It doesn't also fix the problem of whether you function is returning a functioning result or an error.
That's one of the thing that I like about idiomatic Rust. The Result/Option types are implemented as standard language features. You get to use them from the get-go and they reduce lots of if/then/null friction.