Comment on proportional reaction

<- View Parent
calcopiritus@lemmy.world ⁨2⁩ ⁨days⁩ ago

Because it can be done for multiple lines too. And you can do else-if too. Also, “if” and “else” is more recognizable than “?” and “:”

x = if y > 5 {
    println!("Y was over 5");
    z + 5
} else if y < 0 {
    handle_negative_y(y);
    z - y
} else {
    println!("<WARN> unexpected value for y"}
    0
}

source
Sort:hotnewtop