Can structs have static fields?

Does Julia have something similar to static class members in C++, whose values are shared across all objects of the class? If not, is there a good way to emulate it? I don’t want it to be a constant global variable, since I need the variable to be computed at run time.

You want a dynamically valued property that is shared across all instances of a particular type? Sounds like you should use a function.

prop(x::MyType) = # some calculation
8 Likes