julia> ARGS = 2
2
(fresh session)
julia> ARGS
0-element Array{String,1}
julia> ARGS = 2
ERROR: cannot assign variable Base.ARGS from module Main
Stacktrace:
[1] top-level scope at none:0
Is it possible to set a global ARGS = 2
after reading ARGS
(i.e. Base.ARGS
)?
(Probably not?)
Ok, I guess I can do
julia> Base.ARGS
0-element Array{String,1}
julia> ARGS = 2
2
Nevermind.
1 Like
Do you want to modify Base.ARGS
or work with another variable that is incidentally named ARGS
but is otherwise unrelated? If the first, you can do the usual vector manipulations, eg
push!(Base.ARGS, "--runfaster=please")
1 Like
The latter, but thanks anyway!
Defining your own local variable or module global variable named ARGS
is not a problem. The only problem arises in the REPL or similar contexts where Base.ARGS
has already been imported and bound to a local variable ARGS
.
For example:
julia> module Foo
const ARGS = 2
end
Main.Foo
julia> Foo.ARGS
2
or
julia> let ARGS = 3
println("ARGS = $ARGS")
end
ARGS = 3
or
julia> function foo()
ARGS = 4
return ARGS
end
foo (generic function with 1 method)
julia> foo()
4
1 Like