Pārlūkot izejas kodu

[collections] return nil if not found element

Exilon 4 gadi atpakaļ
vecāks
revīzija
ba5264e24d
1 mainītis faili ar 4 papildinājumiem un 2 dzēšanām
  1. 4 2
      Quick.Collections.pas

+ 4 - 2
Quick.Collections.pas

@@ -296,7 +296,8 @@ end;
 
 function TxList<T>.First: T;
 begin
-  if fList.Count > 0 then Result := fList.First;
+  if fList.Count > 0 then Result := fList.First
+    else Result := default(T);
 end;
 
 procedure TxList<T>.FromList(const aList: TList<T>);
@@ -377,7 +378,8 @@ end;
 
 function TxList<T>.Last: T;
 begin
-  if fList.Count > 0 then Result := fList.Last;
+  if fList.Count > 0 then Result := fList.Last
+    else Result := default(T)
 end;
 
 function TxList<T>.LastIndexOf(const Value: T): Integer;