Quantcast
Channel: First steps - JuliaLang
Viewing all articles
Browse latest Browse all 2795

Generate a (mutable) struct which inherits others

$
0
0

Hi.

Is there any way for a (mutable) struct to inherit fields from others?

For example, what I’m trying to do is:

mutable struct Parent
    foo
    bar
end

mutable struct Child <: Parent
end

and use child = Child(); child.foo = 1 (struct field inheritance).
However, an error was raised from the above code: invalid subtyping in definition of Child.

Is there something I missed?

12 posts - 4 participants

Read full topic


Viewing all articles
Browse latest Browse all 2795

Trending Articles