On Wed, Aug 12, 2015 at 9:20 AM, Sisyphuss <[email protected]> wrote: > "The catch clause is not strictly necessary; when omitted, the default > return value is nothing." > Ref: > http://docs.julialang.org/en/latest/manual/control-flow/#exception-handling
So?? As your second example shows, you get the `nothing` if you only have the try clause. You just cannot get both an uncaught error and a return value at the same time. > > On Wednesday, August 12, 2015 at 3:14:51 PM UTC+2, Yichao Yu wrote: >> >> On Wed, Aug 12, 2015 at 9:03 AM, Sisyphuss <[email protected]> wrote: >> > I thought the following code will return the value 1, >> > a = try >> > error() >> > finally >> > 1 >> > end >> >> No, the try block doesn't even return because it throws an error. To >> get a return value when an error happens, use the catch block. >> >> > However, `a` is undefined, as oppose to the `b` in the following code >> > b = try >> > error() >> > end >> > defined as `nothing`. >> >
