How to import custom module in julia

后端 未结 7 2182
抹茶落季
抹茶落季 2020-12-08 19:35

I have a module I wrote here:

# Hello.jl
module Hello
    function foo
        return 1
    end
end

and

# Main.jl
using Hel         


        
7条回答
  •  孤街浪徒
    2020-12-08 19:55

    I have Julia Version 1.4.2 (2020-05-23). Just this using .Hello worked for me. However, I had to compile the Hello module before just using .Hello. It makes sense for both the defined and using scripts of Hello is on the same file.

    Instead, we can define Hello in one file and use it in a different file with include("./Hello.jl");using .Hello

提交回复
热议问题