Learned. Thanks!

On Wednesday, August 12, 2015 at 4:14:58 PM UTC+2, Matt Bauman wrote:
>
> The basic try/catch/finally behaviors have been discussed before.  I think 
> this is a good summary: 
> https://groups.google.com/d/msg/julia-users/Kqn6gNIwD5o/aKE17Nclh3kJ
>
> On Wednesday, August 12, 2015 at 9:25:32 AM UTC-4, Yichao Yu wrote:
>>
>> 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`. 
>> >> > 
>>
>

Reply via email to