Lua - Print tables

Published 2014/03/03 by Admin in LUA
Tags: , , , , ,

Printing out tables is not as simple as printing a normal variable. To print a table we must first get each element in the table by itself. We do this by using the "pairs" keyword.

a={1,2,3,4,"five","elephant","mouse"}

for i,v in pairs(a) do print(i,v) end

Output:

1     1

2     2

3     3

4     4

5     five

6     elephant

7     mouse


my coding

This is a collection of all the coding gems I have found and would like to share with the world!