I have a my_list_1
(list of structs) that defined this way:
struct my_struct {
something[2] : list of int;
something_else[2] : list of uint;
};
...
my_list_1[10] : list of my_struct;
I need to copy this list to a local variable in a method:
foo_method() is {
var my_list_2 : list of my_struct;
my_list_2 = deep_copy(my_list_1);
...
};
The compilation error I get:
*** Error: 'my_list_1' is of type 'list of my_struct', while
expecting type 'any_struct'.
...
my_list_2 = deep_copy(my_list_1);
All variations to write deep_copy()
I've tried caused compilation error... How to copy a list of structs to a local variable? Thank you for your help.
You can't use
deep_copy(...)
directly to copy a list. If you look in the docs,deep_copy(...)
takes a single parameter of typeany_struct
and returns a single struct instance. You have to use it in afor each
loop: