你能检查是否调用了 Exit()
Can you check if Exit() was called
开发人员可以检查 Exit
是否被调用了吗?
try
{do some stuff}
If Condition then
Exit;
finally
{Can I check here if Exit was called without checking Condition again?}
end;
Can I check here if Exit
was called without checking Condition
again?
没有。如果再次检查 Condition
很昂贵,或者有 side-effects,那么您可以使用局部变量来指示 Condition
是 True
.
var
LCondition: Boolean;
...
LCondition := False;
try
// do stuff
LCondition := Condition;
if LCondition then
Exit;
finally
// now check LCondition
end;
开发人员可以检查 Exit
是否被调用了吗?
try
{do some stuff}
If Condition then
Exit;
finally
{Can I check here if Exit was called without checking Condition again?}
end;
Can I check here if
Exit
was called without checkingCondition
again?
没有。如果再次检查 Condition
很昂贵,或者有 side-effects,那么您可以使用局部变量来指示 Condition
是 True
.
var
LCondition: Boolean;
...
LCondition := False;
try
// do stuff
LCondition := Condition;
if LCondition then
Exit;
finally
// now check LCondition
end;