Explorar o código

[collections] return nil if not found element

Exilon %!s(int64=4) %!d(string=hai) anos
pai
achega
ba5264e24d
Modificáronse 1 ficheiros con 4 adicións e 2 borrados
  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;