Help with modules and types

Hi @cesarmarinhorj ! How about something like this (I’ve assumed each module is in a separate script)

In HR.jl

module HR

include("Model.jl")
using .Model  # . means look in local scope rather than registry

include("Staff.jl")
using .Staff

end # module

In Model.jl

module Model

struct Person
    age::Int
end

end # module

In Staff.jl

module Staff

using ..Model # .. means look in scope of parent module

function age(p::Model.Person)
    return p.age
end

end # module

Alternatively Person could be exported from Model and then you could just use Person in Staff.

1 Like