Skip to content

Guide: Bindings without initialization are not explained #16792

Closed
@Florob

Description

@Florob

The last paragraph of section 5 reads:

So, we've cleared up all of the confusion around bindings, with one exception: why does Rust let us declare a variable binding without an initial value if we must initialize the binding before we use it? And how does it know that we have or have not initialized the binding? For that, we need to learn our next concept: if.

Unless I managed to completely miss it, those questions are never answered. I assume there were meant to be examples along the lines of

let y: int;
if x == 5i { y = 3 } else { y = 8 }
println!("{}", y);

and

let y: int;
if x == 5i { y = 3 }
println!("{}", y);

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions