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

Popular posts from this blog

timeout - Handshake_timeout on RabbitMQ using python and pika from remote vm -

gcc - MinGW's ld cannot perform PE operations on non PE output file -

c# - Search and Add Comment with OpenXML for Word -