GC scripting table inside table

Hi, is it possible to clone table (dict) variable in GC scripting or have table inside table data structure? Thanks n advance!

Peter

Parents
  • Hi Peter,

    > is it possible to clone table (dict) variable in GC scripting

    It looks like I need to add a 'Clone()' method to tables. But, in the meantime, this script function will do it:

    table CloneTable(table tbl)
    {
        table result = {};
        foreach (item in tbl)
            result.Add(item.Key, item.Value);
        return result;
    }
    

    > or have table inside table data structure?

    Yes. The keys and values within a table can be of any type you wish, including other tables.


    HTH

    Jeff

Reply
  • Hi Peter,

    > is it possible to clone table (dict) variable in GC scripting

    It looks like I need to add a 'Clone()' method to tables. But, in the meantime, this script function will do it:

    table CloneTable(table tbl)
    {
        table result = {};
        foreach (item in tbl)
            result.Add(item.Key, item.Value);
        return result;
    }
    

    > or have table inside table data structure?

    Yes. The keys and values within a table can be of any type you wish, including other tables.


    HTH

    Jeff

Children
No Data