D equivalent of Python's try..else
    rsw0x via Digitalmars-d-learn 
    digitalmars-d-learn at puremagic.com
       
    Fri Nov 20 21:50:55 PST 2015
    
    
  
On Saturday, 21 November 2015 at 05:45:37 UTC, Shriramana Sharma 
wrote:
> Hello. In Python one has the syntax try..except..else.. where 
> code in the else clause will only be executed if an exception 
> does not occur. (Ref: 
> http://stackoverflow.com/a/22579805/1503120)
>
> In D, is there such an idiomatic/canonical construct? The D try 
> statement only seems to support finally (apart from catch).
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
    
    
More information about the Digitalmars-d-learn
mailing list