Friday, 13 September 2013

Tables In Corona

The table constructor is written using braces
(curly brackets) as in { }

t = {}   -->create a table

k = "x"
t[k] = "tabvalue" --new table entry, 
                  -->with key="x" and value=2.4

print( t[k] )    --> 2.4
print( t["x"] )  --> 2.4
print( t.x )     --> 2.4

t[2] = "tabval2"  --new table entry, 
                  -->with key=2 and value="tabval2"
t[3]= 2.4
print( t[2] )    --> "tabval2"
print( t[3] ) 

No comments:

Post a Comment