This is probably a beginner question, but I could not find anything relevant in the docs or basic tutorials. I am using Julia 1.4.2 (that is the latest stable release), and, as suggested in the docs/tutorials, the Atom editor with Juno. This is on Ubuntu 18.04.
My minimum reproducible example:
function main()
b = 300000
println(b)
println(b, " asdf")
end
main()
seems to sometimes output, as expected,
300000
300000 asdf
but it often outputs only
300000 asdf
The latter "wrong" output seems to occur most often when Julia is stopped, and I click "Run All", which starts Julia and runs the script. What is happening here? I apologize if this is a trivial beginner mistake. Thank you.
The most common function to print the output of the program in the console of Julia is print () and println (). To execute this command we just need to press Enter on the keyboard. The main difference is that the println () function adds a new line to the end of the output.
Julia also supports printf () function which is used in C language to print output on the console. Julia macro (which is used by prefacing it with the @ sign) provides the Printf package which needs to be imported in order to use. printf () is also used as a formatting tool.
Julia provides many methods of printing output on the screen. The Julia program starts with an interactive REPL (Read/ Evaluate /Print / Loop) as default. It helps in outputting the result of the expression on the screen immediately.
printstyled () function helps in printing out message in different colors. Julia also supports printf () function which is used in C language to print output on the console. Julia macro (which is used by prefacing it with the @ sign) provides the Printf package which needs to be imported in order to use. printf () is also used as a formatting tool.
It looks like you are using the Atom IDE.
Unfortunately Atom Juno from time to time is "eating" the first output line of a Julia script - I have seen it few times.
The workaround that seems to work is to force a flush on the standard output cache:
flush(stdout)
This cleans the cache and enforces the communication between Julia REPL and Atom.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With