summary

summary(x)

Return a string giving a brief description of a value. By default returns string(typeof(x)). For arrays, returns strings like "2x2 Float64 Array".

Examples

In the Julia programming language, the function summary(x) is used to generate a brief description of a value. By default, it returns a string representation of the type of the value x. For arrays, it provides a descriptive string.

  1. Get the summary of a numeric value:

    julia> summary(42)
    "Int64"

    This example returns a summary string representing the type of the numeric value 42.

  2. Get the summary of a string:

    julia> summary("Hello, Julia!")
    "String"

    It returns a summary string indicating the type of the given string.

  3. Get the summary of an array:

    julia> arr = [1, 2, 3, 4, 5];
    julia> summary(arr)
    "5-element Vector{Int64}"

    This example returns a summary string representing the type and size of the array.

  4. Custom type summary:
    julia> struct Person
              name::String
              age::Int
          end
    julia> summary(Person("Alice", 30))
    "Person"

    It returns a summary string representing the type of the custom-defined Person object.

Common mistake example:

julia> summary(3.14)
"Float64"

In this example, the summary function correctly returns the summary string representing the type of the floating-point number 3.14. However, a common mistake is to expect the summary to include more detailed information such as the decimal precision. The summary function provides a brief description and does not include such details.

See Also

ascii, base64decode, Base64DecodePipe, base64encode, Base64EncodePipe, bin, bits, bytestring, charwidth, chomp, chop, chr2ind, contains, endswith, escape_string, graphemes, ind2chr, iscntrl, istext, isupper, isvalid, join, lcfirst, lowercase, lpad, lstrip, normalize_string, num2hex, parseip, randstring, readuntil, replace, repr, rpad, rsplit, rstrip, search, searchindex, split, startswith, string, stringmime, strip, strwidth, summary, takebuf_string, ucfirst, unescape_string, uppercase, utf16, utf32, utf8, wstring,

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: