Show an expression and result, returning the result.


  1. Debugging with @show:

The @show macro is used for debugging purposes to display the value of an expression and its result. It helps in understanding the flow of the program and identifying any issues. The macro prints the expression and its evaluated result, returning the result.

julia> n = 10

julia> @show n
n = 10

In the example above, the value of n is displayed along with the expression n = 10. The result of the expression, which is 10, is also returned.

  1. Debugging multiple expressions:

@show can be used to display and examine multiple expressions in a single line.

julia> x = 5

julia> y = 3

julia> @show x y
(x, y) = (5, 3)
(5, 3)

Here, both x and y values are displayed along with their expressions in a tuple format (x, y) = (5, 3). The evaluated result (5, 3) is returned.

Common mistake example:

julia> @show "Hello, world!"
"Hello, world!"

In this example, the provided expression is a string literal. The @show macro expects an expression with a variable or calculation that can be evaluated. It will display the string as is, but it won't provide any additional information or result. Ensure that the expression passed to @show is meaningful for debugging purposes.

Remember, @show is a debugging tool and should be used during development. It is recommended to remove or comment out @show statements once debugging is complete.

See Also

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: