1.lua 406 B

12345678910111213
  1. -- The array is anything in braces separated by commas.
  2. a = {"Lua", "is", "cool", 1, 2, 3, 10 }
  3. -- Actually in fact they are TABLES, not arrays.
  4. -- Getting the length. (amount of elements that index from 1 to n)
  5. n = #a
  6. for i = 1, n do
  7. -- table.concat as you can guess out just concatenates all
  8. -- the elements from table to one string and returns it.
  9. print(table.concat({"a[", i, "] = ", a[i]}))
  10. end