Better HN
topnewbestaskshowjobs
Log inSign up

tmazeika

3 karma · joined Jul 17, 2020 (6y ago) · 1 submissions

Submissions

comment 4y ago · link · parent

The example makes sense when you think of `i` getting reassigned, but in other languages with variable shadowing (think Rust, but Go too when you're in a nested scope) you might replace `i = 2` with `let i = 2` (Rust), in which case the closure closes over precisely the `let i = 2` variable and the expected output differs.