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

powershell Start-Process exit code -1073741502 when used with Credential from a windows service environment -

twig - Using Twigbridge in a Laravel 5.1 Package -

c# - LINQ join Entities from HashSet's, Join vs Dictionary vs HashSet performance -