Re:The Brilliance of “nil” in Objective-C
by nybble41 on Friday April 29, 2022 @01:25PM
(#31208119)
> Some types have no suitable "empty" value. It is dangerous to assume you can always find such a value.
Indeed. In Rust you have Option::unwrap_or_default() for this, which is only available if the underlying type implements the Default trait. It's unfortunately more verbose than `?` but it gives the behavior the GP wants, without making unsafe assumptions like 0 always being a safe default for any integer result.
Indeed. In Rust you have Option::unwrap_or_default() for this, which is only available if the underlying type implements the Default trait. It's unfortunately more verbose than `?` but it gives the behavior the GP wants, without making unsafe assumptions like 0 always being a safe default for any integer result.