The closure looping problem
vou should be very careful while dealing with loops within the closure. Consider the example shown below:
In the above code, for every iteration of‘i’ a new closure will be created. So now if funcs tries to access the value of ‘i’ it will get zero. The same holds for the funcs and funcs , and hence you will get your expected output.