Advertisements
I have a function that I can’t change and it expects type ExpectedType
.
function some_function(some_parameter::ExpectedType)
....
some implementation
....
end
I want to pass my object of type OtherType
.
I decided to inherit OtherType
from ExpectedType
.
struct OtherType <: ExpectedType end
But I’m getting an error: ERROR: invalid subtyping in definition of OtherType
- Is it possible to inherit from non-abst types?
- How can I get the functionality I need?
>Solution :
- It is not possible to inherit from non-abstract type.
- What I would typically do is writing a constructor for
ExpectedType
that takesOtherType
as argument and then callsome_function(ExpectedType(your_object))
.