module_name

module_name(m::Module) -> Symbol

Get the name of a Module as a Symbol.

Examples

julia> module_name(Main)
Symbol("Main")

julia> module_name(Base)
Symbol("Base")

This function returns the name of a Module as a Symbol. Here are a few examples of how it can be used:

  1. Get the name of the current module:

    julia> module_name(Main)
    Symbol("Main")

    This example retrieves the name of the current module, which is Main.

  2. Get the name of a specific module:

    julia> module_name(Base)
    Symbol("Base")

    It retrieves the name of the Base module, which is a built-in module in Julia.

  3. Store module name in a variable:
    julia> module = Main;
    julia> name = module_name(module);
    julia> name
    Symbol("Main")

    This example demonstrates storing the module name in a variable for later use.

Common mistake example:

julia> module_name(1)
ERROR: MethodError: no method matching module_name(::Int64)

In this example, the function module_name is called with an argument of type Int64, which is not a valid module. Ensure that the argument passed to module_name is a valid module object.

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.

*Required Field
Details

Checking you are not a robot: