In e there is no "general" concept of parameterized constructors like in C++, but as mentioned in the other answer, there is a predefined init()
method (without parameters) which gets automatically called whenever a new object of a given type is created.
It is important to notice that init()
is called whenever an object of that type is created, no matter in what way its creation happens: it may be an explicit creation via new
, an implicit creation as part of pre-run generation, and so on.
Another important point: if you just need to assign a specific constant value to a field, you can also specify this value directly at the field declaration, not necessary to do it via init()
, for example:
struct my_struct {
my_list : list of uint = {0}; // field declared with an initializer
};