SOLVED: Odd lua and Corona behaviour

Sorry, you must’ve misunderstood me. When i ran the example in the corona documentation with a few additions i get this:

  
local people = {  
 { name="Bob", age=32, gender="male" },  
 { name="Jane", age=29, gender="female" }  
 }  
  
 print( people[1].name ) -- output: Bob  
 print (people[1].age)  
 people[1].age = 46  
 print (people[1].age)  
 print( people[2]["gender"] ) -- output: female  
 print (people[2].age)  
 people[2].age = "thirty-four"  
 print (people[2].age)  
  

Output:

Bob
32
46
female
29
thirty-four

So why, in this example, can i have a dot notation which is a number but not in my own? [import]uid: 65237 topic_id: 31132 reply_id: 124679[/import]

Ah, I see what you mean. Unfortunately I’m away traveling right now without my computer, so I can’t test what I’m about to suggest, but I’d try the following.

The problem may be that [lua]tables[i][/lua] is not pre-declared as a table. Before your print statement, try putting [lua]tables[i] = {}[/lua] and see of that helps.

  • Andrew [import]uid: 109711 topic_id: 31132 reply_id: 124683[/import]

That works! Thats great, you’ve put me right back on track! Thanks so much for your help! :smiley: [import]uid: 65237 topic_id: 31132 reply_id: 124691[/import]