浏览代码

[collections] return nil if not found element

Exilon 4 年之前
父节点
当前提交
ba5264e24d
共有 1 个文件被更改,包括 4 次插入2 次删除
  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;