I'm trying to learn rust and so far what I understood about returning values is that the value of the last statement inside a block is returned as long there is no semicolon after it.

In the following code the `x + 1`(no semicolon after) is returned and assigned to `y`.

```rust
fn main() {
    let x = 5;

    let y = {
        let x = 3;
        x + 1
    };

    println!("The value of y is: {}", y);
}

```

Output:

```
The value of y is: 4

```

But in the following piece of code how is `counter * 2` is returned although it has a semicolon after it.

```rust
fn main() {
    let mut counter = 0;

    let result = loop {
        counter += 1;

        if counter == 10 {
            break counter * 2;
        }
    };

    println!("The result is {}", result);
}

```

Output:

```
The result is 20

```