Open utterances-bot opened 1 year ago
I like this post very much. One get's some overview or metaknowledge. Next I read your trait.jl recommendation. Best, Claus
Your code is rather tricky :) If I understand it correctly, then 'myInt::Int' is an instance or object variable. Do you have an idea how to a class variable should be coded ? Best, Claus
Hi Mathijs, now another question concerning with 'Functions as custom properties'. I explored your code and generated an object with 'obj789 = MyModule2.MyClass(5)'. Then I looked at the properties of 'obj789' with 'propertynames(obj789)'. I was astonished that only one property appeared: ':myInt'. But in the code of your script all function names appeared as properties ':
Hi Claus, in the case of the 'Functions as custom properties', it will indeed only show the myInt
property. You'll have to manually define the propertynames
function if you want to show something else:
function Base.propertynames(obj::MyClass)
return (:myInt, :print_int, :set_int!)
end
This should also enable tab-completion to work for those names.
You are one of few who really know how to OOP in Julia
:), but usually I prefer FP-style with dispatch. C.
glad to know that this post remains informative :)
Functional Noise
https://www.functionalnoise.com/pages/2023-01-31-julia-class/