We're having a quiet
(NOT) discussion about the PCness of the following code:
function
FindFirstMatch (List: TItemList; Status: TItemStatus):
Integer;
begin
for Result :=
0 to List.Count - 1 do
if List[Result].Status = Status then
Exit;
Result :=
-1;
end;
The main objection
is the use of Exit, but the only simple way I can see to write around that is to
add a local variable:
function FindFirstMatch (List: TItemList; Status:
TItemStatus): Integer;
var
i: Integer;
begin
Result := -1;
for i := 0 to List.Count - 1 do
if List[Result].Status = Status
then
begin
Result:=
i;
Break;
end;
end;
Which
is preferable or what is a tidier method?
Stephen