Better HN
topnewbestaskshowjobs
Log inSign up

akfred

3 karma · joined Jun 17, 2024 (2y ago) · 1 submissions

Submissions

comment 2y ago · link · parent

> No. The code is completely consistent: the closures are different instances of a function that returns the value of 'number' at the moment it gets called. Not the value of 'number' when it gets created.

Isn't that exactly what GP said? And gave an example how to create that effect explicitly in functional languages, using refs?