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

twig - Using Twigbridge in a Laravel 5.1 Package -

jdbc - Not able to establish database connection in eclipse -

firemonkey - How do I make a beep sound in Android using Delphi and the API? -