Importing module in same file

question
#1

How can I import a module in another module in same file in julia ??

0 Likes

#2

Please kindly read the documentation.

0 Likes

#3

I actually read.
But I wanted to know that , is there a way to import module a in moduleb without using include.

0 Likes

#4

The very first example in the section I linked is about this.

Also, please post quoted code.

0 Likes

#5

In that example module Parent contains module Utils so we can use using for importing Utils directly . But In my example module b does not contain module a but are in same file new.jl so if I use using .a it does not work.

0 Likes

#6

Why not just wrap both modules in a module? A .jl file usually contains one module, but that module can have multiple submodules.

PS: Module names are usually uppercase.

0 Likes

#7

@EricForgy are you asking to make a new module(say C) which contains both the module or nesting module A inside module B (like in example given in documentation)???

0 Likes

#8

Either way would be fine. It is up to you :slight_smile:

From your question, it seems you don’t want them nested so you could do something like:

module C

module A
end

module B
using ..A
end

end
3 Likes

#9

Thanks a lot @EricForgy , It worked perfect.:grinning:

1 Like