isconst
isconst([m::Module], s::Symbol) -> Bool
Determine whether a global is declared const
in a given Module
. The default Module
argument is current_module()
.
Examples
julia> module MyModule
const x = 5
y = 10
end
julia> isconst(MyModule, :x)
true
julia> isconst(MyModule, :y)
false
julia> isconst(:π)
true
In the above examples,
isconst(MyModule, :x)
checks if the symbol:x
in the moduleMyModule
is declared as a constant. It returnstrue
sincex
is declared asconst
inMyModule
.isconst(MyModule, :y)
checks if the symbol:y
in the moduleMyModule
is declared as a constant. It returnsfalse
sincey
is not declared asconst
inMyModule
.isconst(:π)
checks if the global symbol:π
is declared as a constant. It returnstrue
sinceπ
is a constant in the global scope.
Note: If no module is specified, current_module()
is used as the default module.
See Also
assert, backtrace, code_llvm, code_lowered, code_native, code_typed, code_warntype, :@which, compilecache, current_module, eval, finalize, finalizer, fullname, function_module, function_name, include_dependency, InterruptException, invoke, isconst, isdefined, isgeneric, methodswith, method_exists, module_name, module_parent, require, subtypes, unsafe_load, workspace, __precompile__,User Contributed Notes
Add a Note
The format of note supported is markdown, use triple backtick to start and end a code block.