0
Why is a for-loop able to use a variable that isn’t defined yet?
5 Respostas
0
I think because the for loop uses a variable and if that specified variable is not defined yet, it will be defined only inside the loop.
+ 2
Let's say you write:
For letter in 'abcde':
Then letter will not be undefined, but 'a' in first iteration, 'b' in second and so on.
+ 1
Thank you. So it means that variable is defined by foor-loop at the beginning, when it starts. Each time initializing it to the current element of the loop iteration.
0
You may see instances of: for (int i = 0; i>=10; i++){} in Java, or in any other programming languages. Which programming language you are using?