How to wrap using JuMP inside a function

I want to place “using JuMP” inside a function as follows

function test()

    using JuMP
    ...
end

However, it gives an error syntax: "using" expression not at top level, is there a way to work around it?

you need to make a module instead

Why do you need to do this?

2 Likes

Here you might find your answer: Frequently Asked Questions · The Julia Language

4 Likes