[OT] Some neat ideas from the Kotlin language
Thiez via Digitalmars-d
digitalmars-d at puremagic.com
Fri Feb 19 04:59:02 PST 2016
On Friday, 19 February 2016 at 12:28:14 UTC, Nemanja Boric wrote:
> What Rust is doing:
>
> ```
> let foo: Option<i32> = bar();
>
> let new_stuff = match foo {
> Some(x) => x,
> None => 0
> }
> ```
>
> (or similar, I don't have compiler handy).
I think most would write that as:
let new_stuf = bar().unwrap_or(0);
When you use the methods on `Option` you rarely need to match.
More information about the Digitalmars-d
mailing list