Short answer: don’t do this. Julia style is to do method(object, args…)
and not object.method(args…)
, and to define methods outside of struct
definitions (with the exception of inner constructors). Trying to force OOP syntax on Julia will lead to non-idiomatic code, re-introduces the expression problem, and will be slow if you’re not clever.
Long answer: see many previous discussions of this topic, e.g.: