| ▲ | lock1 3 hours ago | |
Well, in a language with nullable reference types, you could use something like
to express what you want.But exactly like Go's error handling via (fake) unnamed tuple, it's very much error-prone (and return value might contain absurd values like `(someInstanceOfT, false)`). So yeah, I also prefer language w/ ADT which solves it via sum-type rather than being stuck with product-type forever. | ||
| ▲ | _flux an hour ago | parent [-] | |
How does this work if it is given an empty list as a parameter? I guess if one is always able to construct default values of T then this is not a problem. | ||