Skip to content

Latest commit

 

History

History
56 lines (37 loc) · 1.33 KB

File metadata and controls

56 lines (37 loc) · 1.33 KB

Concat<T> class method

Project: Array Utilities Unit

Unit: DelphiDabbler.Lib.ArrayUtils

Record: TArrayUtils

Applies to: ~>0.1

class function Concat<T>(const A, B: array of T): TArray<T>;
  static;

Description

Returns a concatenation of two arrays with elements of the same type.

The returned array contains shallow copies of the two arrays.

Parameters:

  • A - The first array to be copied.

  • B - The second array to be copied.

Returns:

  • The required concatenation comprising a copy of A followed by a copy of B.

Note

If a deep copy of the concatenated array is required, pass the return value of Concat<T> to the deep copying overload of Copy<T> along with a suitable TCloner<T> implementation.

Example

procedure Concat_Eg;
var
  A, B, Got, Expected: TArray<Integer>;
begin
  A := TArray<Integer>.Create(1, 2, 3, 4);
  B := TArray<Integer>.Create(42, 56);
  Got := TArrayUtils.Concat<Integer>(A, B);
  Expected := TArray<Integer>.Create(1, 2, 3, 4, 42, 56);
  Assert(TArrayUtils.Equal<Integer>(Expected, Got));
end;

See Also