Try to work with 2 Modules, but get an error

I’m new to Julia. I’m defining a struct in one module ‘myModule’ and try to get an object from another module ‘myMain’.

myModule.jl can compile but not myMain.jl, getting this error. I’m also pasting code at bottom. Appreciate your help.

julia> using myMain
[ Info: Precompiling myMain [top-level]
ERROR: LoadError: syntax: expected “end” in definition of function “entrance”
Stacktrace:
[1] top-level scope at C:\Users\YYANGC\Desktop\Y100\SystemModeling\WearLeveling\JuliaDev\workspace\src\myMain.jl:5
[2] include(::Module, ::String) at .\Base.jl:377
[3] top-level scope at none:2
[4] eval at .\boot.jl:331 [inlined]
[5] eval(::Expr) at .\client.jl:449
[6] top-level scope at .\none:3

myModule.jl:

module myModule

export myObj, create, dump

mutable struct myObj
a :: Int
b :: Int
myObj(
a :: Int,
b :: Int
) = new(a,b)
end

function create(x::Int, y::Int)
myObj(x,y)
end

function dump(o::myObj)
println(o.a)
end
end

myMain.jl

module myMain
using myModule

function entrance
o1 = myModule.create(10,20)
myModule.dump(o1)
end

entrance()

end

Welcome to Julia,

The error message indicates a problem with the end of function entrance. You apparently missed the parenthesis in the function definition. It should be function entrance().

Please use the code quoting feature of Discourse by enclosing it with tripple `, this will increase the chances of people helping you.

2 Likes

Thank you for helping and suggestion. Appreciate it.