lua - Initialise table with keys with for loop -
is possible initialise lua table has keys , values loop? tried this, of course creating new key called "name" instead of referring variable "name".
local mytable = {a = "", b = "", c = ""} function main() name, value in pairs(mytable) mytable.name = math.random(1000) end outputtable(mytable) end function outputtable(t) name, value in pairs (t) print(name,value) end end main()
output:
b name 754 c
Comments
Post a Comment