A variable is only valid inside a certain scope. The memory occupied by the variable’s value is freed at the end of the scope. In the following example, the scope is explicitly represented by curly braces:
{
let x = 1;
}Outside of the scope, the variable does not exist:
{
let x = 1;
}
xError: the binding `x` is available in a different scope in the same function
╭─[ command_2:1:1 ]
│
2 │ let x = 1;
│ ┬
│ ╰── help: the binding `x` is available in a different scope in the same function
───╯