How to print ALL output of a cell in Julia Jupyter notebook?

Viewed 86

I am running Julia through (Anaconda) Jupyter notebook. When I run a cell like this

5 + 6
3 + 17

The output is

[out:] 20

How can I print out the output of all lines, i.e.,

[out:] 11

[out:] 20

1 Answers

But there is only one output of the cell! Expressions have no "output", they have a value. The cell behaves like a block:

output = begin
    5 + 6
    3 + 17
end
show(output)

The expressions in the begin block are sequenced (i.e., evaluated in order, so that their side effects are run), and the end result is then the result of the block. This end result is printed.

If you want to see the intermediate results of the individual expressions, you have to either split the block, or use side effects:

println(5 + 6)
3 + 17
Related