Comment on Why does the for loop repeat in this recursion?
mac@programming.dev 11 months agoWhen the draw function calls itself it yields control to that new function its calling. When that function ends it takes back control and continues doing what it was doing.
This means all of the for loops in all of the functions will execute. Draw(1) will do the for loop and then return as it hits the end of the function (standard behaviour when you reach the end of a function even if theres no return statement). Then draw(2) will do the for loop and then return, etc. all the way up
All parts of a function are recursive, theres no such thing as a non recursive part