I have a struct with a list:
struct my_struct {
my_list : list of uint;
// other fields
};
I would like to build something similar to cpp class constructor
:
when I allocate my_struct
using new
operator, my_list
will be initiated to have one zero element - my_list == { 0 }
;
Is there a way to build a struct constructor in e?
Thank you for your help
yes, any_struct has the init() method. it is called when the struct is created with new(), and also when the struct is generated (before the generation, the constraints solving, starts).
if you want this list to always have same init value, regardless if created with new or with gen, mark this list field as do-not-generate.
struct my_struct {
!l : list of_ int;
init() is also {
l = {0};
};
};