I wanted to create a struct with the
new() construct, mostly for convenience reasons, I wanted to identify it’s fields by their names (as it will have a lot of fields but will be read-only after initialization). So I wrote something along the lines of:
struct Tytto f1 function Tytto() t = new() t.f1 = 1 return t end end
But Julia reports that I cannot call
setfield() on an immutable struct when executing
Tytto(). So my questions is, is there a way to initialize a struct by referring to field names in the constructor?