我有一个过程声明如下:
procedure MyProc(List: Array of string);
我想知道如何检查 List 参数是否为空。例如:
procedure MyProc(List: Array of string);
begin
if List=[] then // here I want to check if the List array is empty
//do something
else
//do something else
end;
我该如何做到这一点?
MyProc(const List: array of string)
,因为在你的代码中,在调用MyProc
过程之前,所有字符串都会被复制到一个临时数组中。而if pointer(List)=nil then
是检查动态数组是否为空的最快方法。 - Arnaud Bouchezconst
,就不会有这些AddRef/DecRef隐藏过程调用。 - Arnaud Bouchez