Просмотр исходного кода

if

is an expression.  semicolons are a little weird, but they do make
sense.  (why weird?  because you don't have to write them in the body of
`main`, supposedly because it returns nothing.)
Lucas Stadler лет назад: 10
Родитель
Сommit
5d50eb3eff
1 измененных файлов с 5 добавлено и 1 удалено
  1. 5 1
      rust/book/src/main.rs

+ 5 - 1
rust/book/src/main.rs

2
    let x = 5;
2
    let x = 5;
3
3
4
    println!("Hello, World!");
4
    println!("Hello, World!");
5
    println!("THE number is {}", x);
5
    if x == 42 {
6
        println!("It's THE ANSWER!");
7
    } else {
8
        println!("Meh, it's just a number, {}.", x);
9
    }
6
}
10
}