% if

<small>There is a new edition of the book and this is an old link.</small>

> An `if` expression allows us to branch our code depending on conditions.

```rust
fn main() {
    let number = 3;

    if number < 5 {
        println!("condition was true");
    } else {
        println!("condition was false");
    }
}
```

---

Here are the relevant sections in the new and old books:

* **[In the second edition: Ch 3.05 — Control flow][2]**
* <small>[In the first edition: Ch 3.5 — if][1]</small>


[1]: first-edition/if.html
[2]: second-edition/ch03-05-control-flow.html#if-expressions
