D equivalent of Python's try..else

Shriramana Sharma via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Fri Nov 20 21:55:50 PST 2015


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?

-- 
Shriramana Sharma, Penguin #395953


More information about the Digitalmars-d-learn mailing list