Multiple Parent Types: How to go about it?

In a lot of cases I’d guess you can just reorg what you’ve written to make it work.

abstract struct AbstractJobType end
struct Soldier <: AbstractJobType end
struct Civilian <: AbstractJobType end

abstract struct AbstractSex end
struct Male <: AbstractSex end
struct Female <: AbstractSex end

struct Person{J,S} where {J<:AbstractJobType, S<:AbstractSex}
job::J
sex::S
end

and then when defining methods you define them somewhat explicitly

info(p::Person{Soldier,Male}) = ...

or something to this effect.

Hopefully someone with more knowledge on this style can clarify or correct this answer.

5 Likes