I wondered if there is an equivalent to the browser()
statement available in RStudio for debugging purposes for Julia (I am using the Juno IDE at the moment).
The R
function browser()
halts execution and invokes an environment browser
when it is called. So, in principle, we can put browser()
anywhere in our code to stop in this particular line and see what's stored in the environment at that moment, which is terrific for debugging purposes.
For instance, the code below will stop when i>3
. Hence, that's exactly what we will see in the environment browser
available in RStudio, where we will observe that i=4
at that moment in the code.
for (i in 1:5) {
print(i)
if (i>3) {
browser()
}
}
[1] 1
[1] 2
[1] 3
[1] 4
Called from: eval(ei, envir)
Browse[1]>