[Resolved] boolean in array becomes a string?

Trying to initialize some values in a nested array, but my boolean (false) types as a string, not a boolean, when I read it out. See result of the print statement. Is there another syntax for this? Or a way to force a boolean type?
[lua]contactTable = {}
for i =1, 10 do
contactTable[i] = {}
contactTable[i][1] = “Enter contact email”
contactTable[i][2] = false
end
print ( type ( contactTable[1][2] ))[/lua]
[import]uid: 96383 topic_id: 29449 reply_id: 329449[/import]

Hi there,

Not sure what the issue is, because I copy-pasted that exact code, and the output I got for the print statement is boolean, as expected.

Is this a snippet of code from a larger module? If so, I would guess that somewhere else in your module you may be mistakenly assigning a string to that index of the table.

  • Andrew [import]uid: 109711 topic_id: 29449 reply_id: 118257[/import]

It’s printing out “boolean” because you’re printing the ‘type’ of contactTable[1][2], which is a boolean.

Just print it without the ‘type’.

[lua] print ( contactTable[1][2] ) [/lua]

That should print “false”.

Brian. [import]uid: 40731 topic_id: 29449 reply_id: 118259[/import]

Problem is I need it to be a boolean. I only provided the print (type) line to illustrate the fact that it is not a boolean when referenced as contactTable[1][2], but a string. I need the boolean value of false at that index position. Any ideas?

[import]uid: 96383 topic_id: 29449 reply_id: 118263[/import]

Still not sure I understand the issue. When you run the exact code you pasted initially, what is the exact output you see, and what is the output you expect to see?

  • Andrew [import]uid: 109711 topic_id: 29449 reply_id: 118265[/import]

Problem resolved! Thanks for the input. [import]uid: 96383 topic_id: 29449 reply_id: 118268[/import]