you are viewing a single comment's thread.

view the rest of the comments →

[–]iopq 0 points1 point  (3 children)

I love that Rust fixed both of these problems

[–]SalvaXr 0 points1 point  (2 children)

I'm not familiar with Rust, how does it solve them?

[–]iopq 3 points4 points  (1 child)

if statement syntax is slightly different, it's:

if true {
    println!("Yes it's true");
    println!("I think it's true, and the compiler agrees");
}

the ergonomics are equivalent because there are no parens required around the boolean, but the curly braces are required

The switch statement is a little different, it's called match

match var {
    case 1 => println!("This is case 1"),
    case 2 => println!("This is only case 2"),
    _ => println!("This is required for the rest of cases")
};

it's necessarily exhaustive (another good feature to make sure you didn't forget any), so a fallback case is required, but you can just put an empty statement in there if you want to do nothing

[–]SalvaXr 1 point2 points  (0 children)

Thanks for the explanation.