This stumps me at the moment: How do I refer to f
in the submodule?
module A
f(x) = 10*x
module SubA
g(x) = f(1)
end
end
using .A
@show A.SubA.g(3)
This stumps me at the moment: How do I refer to f
in the submodule?
module A
f(x) = 10*x
module SubA
g(x) = f(1)
end
end
using .A
@show A.SubA.g(3)
You need to pull f
into SubA
from A
like so:
julia> module A
f(x) = 10*x
module SubA
using ..A: f
g(x) = f(1)
end
end
Main.A
julia> using .A
julia> A.SubA.g(3)
10
the ..A
basically means $EnclosingModule.A
like in unixy directories.
Of course, I’ve used this notation many times before. I don’t know, when I looked at this particular example I couldn’t see it. Silly me.
Thanks.