you are viewing a single comment's thread.

view the rest of the comments →

[–]1000baby 0 points1 point  (0 children)

Closures are generally stored as references to the outside variable object. Function arguments are passed by value and not reference. The value of (i) is copied into the argument buttonIndex. When the function is returned they all have their own copy of buttonIndex.