The critical thing is that even though $item seems to have gone out of scope once shoppingList() has returned, the code reference it returns has a copy of $item in it. This copy retains the value $item had at the time that shoppingList returned the reference.
So you can call each of these references as many times as you wish, and the first thing it tells you you need will always be the same as what you gave the routine when you created the code reference with shoppingList();
In reply to Re: Help with the concept of closures.
by bobn
in thread Help with the concept of closures.
by DigitalKitty
For: | Use: | ||
& | & | ||
< | < | ||
> | > | ||
[ | [ | ||
] | ] |