Re:Eight years of Go
by erik_seaberg on Saturday November 11, 2017 @06:03PM
(#15678686)
Java gets this right.
Because "i" is effectively final, each Runnable closes over the correct value for that iteration. If "i" were being reassigned, the closure wouldn't be allowed to use it, you'd have to decide whether to close over a final copy or a reference to a mutable object that holds the latest value over time (a one-element array is the idiom).
[ Parent
| on HN ]
There are no comments on this comment yet.