I don't get them, what are they and how are they used?
The variable 'i' is commonly used in subscripts and other sets, often in math. When used in a loop for example:
1 | for i = 1 , 3 do |
2 | print ( 'Number: ' ..i) |
3 | end |
Variable i will be substituted as the number, and the value for 'i' increments every time it changes.
Also, 'i' stands for index, or iterator.
If I am correct its just a short way of defining a variable. for example.
1 | i = 2 + 2 |
2 | h = i* 2 |
3 | end |
don't want to embarrrass myself, hope thats correct
Well, for "for" loops i is the common iterator, i = 1 means that i is equal to 1,
1 | for i = 1 , 10 do -- i is just a variable name, you can name it anything |
2 | print (i) -- every time the script runs i is incremented by 1 (or any other number, if You do that) |
3 | end |
the "i" can be anything, so this will work too:
1 | for spaghetti = 1 , 10 do |
2 | print (spaghetti) |
3 | end |
the number after the variable is just what number it starts at, for example
1 | for spaghetti = 15 , 10 do -- the loop will start at 15, and iterate by 1(or -1) until it reaches 10 |
2 | print (spaghetti) |
3 | end |