View Single Post
05/30/14, 10:10 AM   #6
Harven
 
Harven's Avatar
AddOn Author - Click to view addons
Join Date: Apr 2014
Posts: 135
Originally Posted by Stormknight View Post
Tables are pretty awesome.

Something that often confuses new LUA coders - table entries start with an key/index of 1.

Lua Code:
  1. local newTable = {}
  2. table.insert(newTable,"First Line")
  3. d(newTable)

The contents of the table is a single entry, with a key of 1 (not zero, as you would expect with something like C++).
But if you like 0 as your first element, then you can do:
Lua Code:
  1. table = { [0] = "firstElement", "secondElement", "thirdElement"}

Last edited by Harven : 05/30/14 at 10:12 AM.
  Reply With Quote