Description
Appends all elements from Source to the end of this array in a single allocation. Accepts arrays with compatible but different element or allocator types, a raw pointer + count pair, an initializer list, or any contiguous range.
Caveats & Gotchas
- • Self-append is explicitly checked and will assert — you cannot do MyArray.Append(MyArray). Create a copy if you need to duplicate the array into itself.
- • The move overload (TArray&&) leaves the source array empty after the call — the elements are relocated, not copied.
Signature
void Append(const TArray<OtherElementType, OtherAllocatorType>& Source) Parameters
| Name | Type | Description | Default |
|---|---|---|---|
| Source | const TArray<OtherElementType, OtherAllocatorType>& | The array whose elements are appended to this array. | — |
Return Type
void Examples
Merge two actor lists C++
TArray<AActor*> AllActors;
TArray<AActor*> StaticActors = GetStaticActors();
TArray<AActor*> DynamicActors = GetDynamicActors();
AllActors.Append(StaticActors);
AllActors.Append(DynamicActors); Append a raw C array C++
float RawData[] = { 1.f, 2.f, 3.f };
TArray<float> Values;
Values.Append(RawData, UE_ARRAY_COUNT(RawData)); See Also
Tags
Version History
Introduced in: 4.0
| Version | Status | Notes |
|---|---|---|
| 5.6 | stable | — |
Feedback
Was this helpful?