There is a clear mention of the scope for "const"
There is no clear discussion about the scope of "let"
The response to Q1 could be implied but I got it wrong the first time based on the chapter content.
My background is from C, C++, Java, javascript which all allow non-const global variables.
Question 1
Which of the following statements is correct about the difference between using let and const to declare a variable?
The response "const can be used in the global scope, and let can only be used in a function"
Suggested fix:
Perhaps add clarification about the scope of "let" to the section. I didn't get it from the chapter text.
I have searched open and closed issues and pull requests for duplicates, using these search terms:
-
I have checked the latest
main
branch to see if this has already been fixed, in this file:URL to the section(s) of the book with this problem:
https://rust-book.cs.brown.edu/ch03-01-variables-and-mutability.html
Description of the problem:
There is a clear mention of the scope for "const" There is no clear discussion about the scope of "let"
The response to Q1 could be implied but I got it wrong the first time based on the chapter content. My background is from C, C++, Java, javascript which all allow non-const global variables.
Question 1 Which of the following statements is correct about the difference between using let and const to declare a variable? The response "const can be used in the global scope, and let can only be used in a function"
Suggested fix:
Perhaps add clarification about the scope of "let" to the section. I didn't get it from the chapter text.