What is the meaning of (i) in (for i = [number],[number] do)?

Tho I can use " for i = [number],[number] do ", I still don’t know its meaning smoothly.

What does “i” refer to?

1 Like

Basically it is a loop in ranged.
Example: for i=1, 10 do
“i” will started from 1 and increase by 1 everytime until it reached 10.
That is how i understand it.

2 Likes

Why will it increase by 1 everytime? Why doesn’t it increase by 2 for example?

1 Like

It is default as 1 cuz not everyone take effort to set it.
If you want to increase by 2 write "for i = 1, 10 , 2 do
It is like this for i = “Starter number”, “Goal number”, “Number increase every loop” do

3 Likes

Aha I get it.

Thank you so much:)

2 Likes

it doesn’t have to be i
it could be whatever (except non strings)

e.g

for gh = 10, 0, -1 do

end

--gh is i

Oh, so it is just a loop, but " i " is a common used variable in this loop, right?

2 Likes

yup, people use i because it is easy to remember as short for index

1 Like

Ah, I get it.

Thank you mate:)

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.