My question is: how can I overload a specific method inside a specific class in Julia?
In other words, suppose I have the following class definition:
type Sometype
prop::String
setValue::Function
function Sometype()
this = new ()
this.prop = ""
this.setValue = function(v::Real)
println("Scalar Version was Invoked!")
end
this.setValue = function(v::Vector{Real})
println("Vector Version was Invoked!")
end
this.setValue = function(v::Matrix{Real})
println("Matrix Version was Invoked!")
end
return this
end
end
So, when I say in my main code:
st = Sometype()
st.setValue(val)
depending on whether it is val scalar , vector or matrix , it will refer to the corresponding version of the method setvalue. Right now, with the above definition, he redefines the definitions setvaluelast (in this case, the matrix version).
source
share