Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Conditional: else - if

  • arms

  • else if

  • elseif

  • elsif

  • The code pathes in an if-else-if statement are called "arms".

  • comparison_chain

#[allow(clippy::comparison_chain)]
fn main() {
    let x = 23;
    let y = 32;
    if x > y {
        println!("x is bigger than y");
    } else if x < y {
        println!("x is smaller than y");
    } else {
        println!("x is equal to y");
    }
}
x is smaller than y