Search code examples
delphitry-finally

Does the statements in the Finally block still execute in this piece of code ?


Will finally block execute? if I pass exit; ?

procedure someProc;
begin
    Try
      Exit;
    finally
     do_something;
    end;
end;

Solution

  • Yes, finally blocks always execute, even if you call Exit somewhere. They wouldn't be worth much if they weren't always executed.