Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Guide: Bindings without initialization are not explained #16792

Closed
Florob opened this issue Aug 27, 2014 · 1 comment · Fixed by #17107
Closed

Guide: Bindings without initialization are not explained #16792

Florob opened this issue Aug 27, 2014 · 1 comment · Fixed by #17107

Comments

@Florob
Copy link
Contributor

Florob commented Aug 27, 2014

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);
@steveklabnik
Copy link
Member

Yep, that was my intention, and I missed out on it. Good call.

steveklabnik added a commit to steveklabnik/rust that referenced this issue Sep 8, 2014
There isn't a good way to fit this in, so let's just not
mention it.

Fixes rust-lang#16792.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants