Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Your ternary demo needs to be written thus for it to work:

    let ter_demo = if a.is_none() { 3 } else { 2 };
You can also often use pattern matching:

    let ter_demo = match a { None => 3, _ => 2 };


Yeah, I wrote the example out of my head, so no surprises there. Thanks, though.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: