Write (to the default output stream) a canonical (un-decorated) text representation of a value if there is one, otherwise call show. The representation used by print includes minimal formatting and tries to avoid Julia-specific details.


In the Julia programming language, the function print(x) is used to write a canonical text representation of a value to the default output stream. If a canonical representation exists for the value, it is printed without any adornments. If no canonical representation exists, print calls the show function to display the value. The representation used by print includes minimal formatting and aims to avoid Julia-specific details.

Common examples of using the print function:

  1. Print a string:

    julia> print("Hello, world!")
    Hello, world!
  2. Print an integer:

    julia> print(42)
  3. Print a floating-point number:

    julia> print(3.14)
  4. Print a boolean value:

    julia> print(true)
  5. Print an array:

    julia> print([1, 2, 3, 4])
    [1, 2, 3, 4]
  6. Print a custom object:

    julia> struct Person
    julia> p = Person("Alice", 25)
    julia> print(p)
    Person("Alice", 25)

Note that the print function does not append a newline character (\n) at the end. If you want to add a newline after printing, you can use println instead.

Please note that print writes to the default output stream, which is typically the console.

See Also

:@printf, :@sprintf, display, displayable, dump, info, isprint, print, println, print_escaped, print_joined, print_shortest, print_unescaped, print_with_color, pushdisplay, redisplay, show, showall, showcompact, sprint, versioninfo,

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: