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

Problem with importing a module after include

$
0
0

Hi,

I am getting this warning after I run include and then import my module
So I created a folder with two julia scripts Mymod.jl and test.jl :

MyMod.jl contains:

module MyMod
x=1
end

And in test.jl :

include("MyMod.jl")
import .MyMod
MyMod.x

After the import I get the following:
WARNING: could not import Main.MyMod into Main
And I can’t use MyMod.x

If I try “using”:

ERROR: UndefVarError: MyMod not defined
Stacktrace:
 [1] include_string(::Function, ::Module, ::String, ::String) at ./loading.jl:1088

I started Julia from the same directory where I store the two scripts.

6 posts - 3 participants

Read full topic


Viewing all articles
Browse latest Browse all 2795

Trending Articles