Blurry Sterk
Blurry Sterk

Reputation: 1607

Can you check if Exit() was called

Can a developer check if Exit was called?

try
  {do some stuff}
  If Condition then
    Exit;
finally
  {Can I check here if Exit was called without checking Condition again?}
end;

Upvotes: 2

Views: 238

Answers (1)

David Heffernan
David Heffernan

Reputation: 612963

Can I check here if Exit was called without checking Condition again?

No. If checking Condition again is expensive, or has side-effects, then you can use a local variable to indicate that Condition was True.

var
  LCondition: Boolean;
...
LCondition := False;
try
  // do stuff
  LCondition := Condition;
  if LCondition then
    Exit;
finally
  // now check LCondition
end;

Upvotes: 6

Related Questions