Reputation: 1607
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
Reputation: 612963
Can I check here if
Exit
was called without checkingCondition
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