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:xin the moduleMyModuleis declared as a constant. It returnstruesincexis declared asconstinMyModule.isconst(MyModule, :y)checks if the symbol:yin the moduleMyModuleis declared as a constant. It returnsfalsesinceyis not declared asconstinMyModule.isconst(:π)checks if the global symbol:πis declared as a constant. It returnstruesinceπ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.