Get the concrete type of x.


  1. Get the type of a variable:

    julia> x = 5;
    julia> typeof(x)

    This example returns the concrete type Int64 of the variable x.

  2. Check the type of a string:

    julia> str = "Hello, Julia!";
    julia> typeof(str)

    It returns the concrete type String of the string variable str.

  3. Determine the type of an array:
    julia> arr = [1, 2, 3, 4, 5];
    julia> typeof(arr)

    It returns the concrete type Array{Int64,1} of the array arr.

Common mistake example:

julia> typeof(10, 20, 30)
ERROR: MethodError: no method matching typeof(::Int64, ::Int64, ::Int64)

In this example, the typeof function is mistakenly used with multiple arguments. The typeof function expects only one argument, so ensure that you pass a single value or variable to it.

See Also

BigFloat, BigInt, Dict, eltype, fieldtype, Float32, Float64, IntSet, isa, isalnum, isalpha, isascii, iseltype, isequal, isgraph, isimmutable, isinteractive, isleaftype, isnull, ispunct, isspace, issubtype, keytype, Nullable, NullException, promote_type, typeintersect, typejoin, typemax, typemin, typeof, Val, valtype,

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

Checking you are not a robot: