Thread: lua language
View Single Post
12-02-14, 10:38 PM   #7
Phanx
Cat.
 
Phanx's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2006
Posts: 5,617
Originally Posted by sirann View Post
Then I saw
Lua Code:
  1. for i=1, gridWidth, 1 do    
  2.     grid[i] = {}
  3. end
which I'm pretty sure creates nested tables at keys of 1-9-1, which is a bit redundant. Should just be
Lua Code:
  1. for i = 1, gridWidth do
While it is redundant, it's not for the reason you think -- the third parameter in a for loop just specifies how much to increment i on each loop. 1 is the default value, so you do not need to explicitly specify 1. However, if you wanted to iterate through all even numbers from 4 to 9000, for example, you could do this:
Code:
for i = 4, 9000, 2 do ... end
__________________
Retired author of too many addons.
Message me if you're interested in taking over one of my addons.
Don’t message me about addon bugs or programming questions.