(no title)
lock1 | 2 months ago
fn find<T>(self: List<T>) -> (T, bool)
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|2 months ago
I guess if one is always able to construct default values of T then this is not a problem.
maccard|2 months ago
this is how go handles it;
is expected to return `"", errors.New("invalid state")` which... sucks for performance and for actually coding.