Hello all, I was very recently introduced to Julia, and I’ve been playing around with the REPL when I ran into something that I found odd.
Maybe I’m just used to how some other languages work, but the behavior of try/catch surprised me. Here’s a simple example:
f(z) = try z + 1 catch println("error") end
…works fine if z is numeric (or even a character, which I find neat). Should z be something non-mathematically-inclined (such as a string), “error” is printed as one would expect. However, should z be an undefined variable, rather than printing the error notice, it generates a stack trace:
f(i) ERROR:UndefVarError: i is not defined Stacktrace:  top-level scope at none:0
I would have expect this still to print “error” instead of crashing. Is this just how Julia works (requiring other code to catch that circumstance) or am I misusing the command somehow?
I’ve poked around here and didn’t find a similar topic, but apologies if I’ve overlooked it.