Преглед на файлове

[collections] fixed exception if no results

Exilon преди 4 години
родител
ревизия
a4d91f69e9
променени са 1 файла, в които са добавени 2 реда и са изтрити 2 реда
  1. 2 2
      Quick.Collections.pas

+ 2 - 2
Quick.Collections.pas

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