D equivalent of Python's try..else
    rsw0x via Digitalmars-d-learn 
    digitalmars-d-learn at puremagic.com
       
    Fri Nov 20 22:15:19 PST 2015
    
    
  
On Saturday, 21 November 2015 at 05:55:53 UTC, Shriramana Sharma 
wrote:
> rsw0x wrote:
>
>> scope(failure) can be used to run code when an exception is
>> thrown inside the scope, and scope(success) only triggers if 
>> the
>> scope exited successfully
>> 
>> http://ddili.org/ders/d.en/scope.html
>
> Thanks but I know that and it executes only at the point of 
> scope exit. But I want some code to run immediately after the 
> try clause but only if an exception did not occur.
>
> The Python else clause is for code which should be run only if 
> an exception never occurred i.e. even if one occurred and it 
> was handled. It will be executed before `finally`. Is there a D 
> equivalent?
Put the scope(success) inside the try block?
    
    
More information about the Digitalmars-d-learn
mailing list