

Print("alternatetable is ",alternatetable) only variable released and and not table Print("alternatetable Element at index wow is ",alternatetable) Print("alternatetable Element at index 1 is ",alternatetable) alternatetable and mytable refers to same table Print("mytable Element at index wow is ",mytable) Print("mytable Element at index 1 is ",mytable) Print("Type of mytable is ",type(mytable)) When there are no reference to a table,then garbage collection in Lua takes care of cleaning up process to make these unreferenced memory to be reused again.Īn example is shown below for explaining the above mentioned features of tables. When a is set to nil,table will be still accessible to b. No separate memory is allocated separately for b. When we have a table a with set of elements and if we assign it to b,both a and b refer to the same memory. lua garbage collection will take care of releasing memory It is to be known that there is no fixed relationship between a variable that holds reference of table and the table itself. Lua uses a constructor expression to create an empty table. Tables are called objects and they are neither values nor variables. When we access a method string.format,it means,we are accessing the format function available in the string package. Lua uses tables in all representations including representation of packages. Tables have no fixed size and can grow based on our need. Lua uses associative arrays and which can be indexed with not only numbers but also with strings except nil. Tables are the only data structure available in Lua that helps us create different types like arrays and dictionaries.
