This is a new site that's currently running on alpha code. There are going to be bugs. If you discover any, please report them on the site's issues page (GitHub account required). Thanks.
Warning: Many URLs are going to change. Refer to the README file to discover which library project's documentation has been completed.
Project: Array Utilities Unit
Unit: DelphiDabbler.Lib.ArrayUtils
Record: TArrayUtils
Applies to: ~>0.1
class procedure Push<T>(var A: TArray<T>; const AValue: T);
static;
Appends a value to a given array
The length of the array is increased by one.
Parameters:
A - Array to which the element is to be added. The array is updated in place when the element is added.
AValue - The element to be added to the array.
This example appends three elements to a previously empty string array.
procedure Push_Eg;
var
A, Expected: TArray<string>;
begin
A := TArray<string>.Create();
TArrayUtils.Push<string>(A, 'foo');
Expected := TArray<string>.Create('foo');
Assert(TArrayUtils.Equal<string>(Expected, A, SameStr));
TArrayUtils.Push<string>(A, 'bar');
Expected := TArray<string>.Create('foo', 'bar');
Assert(TArrayUtils.Equal<string>(Expected, A, SameStr));
TArrayUtils.Push<string>(A, 'baz');
Expected := TArray<string>.Create('foo', 'bar', 'baz');
Assert(TArrayUtils.Equal<string>(Expected, A, SameStr));
end;