TArray::Add

Adds a new item to the end of the array, possibly reallocating the whole array to fit.

Windows
MacOS
Linux

References

Module

Core

Header

/Engine/Source/Runtime/Core/Public/Containers/Array.h

Include

#include "Containers/Array.h"

Syntax

SizeType Add
(
    ElementType && Item
)

Remarks

Adds a new item to the end of the array, possibly reallocating the whole array to fit.

Move semantics version.

Returns

Index to the new item

Parameters

Parameter

Description

Item

The item to add

Example Code

ArraySnippet.cpp at line 14:

void ArraySnippet::PushBack()  
{  

    // Push new elements to the back of the array.  
    StringArray.Add(TEXT("Hello"));  
    StringArray.Add(TEXT("Unreal"));  
    StringArray.Add(TEXT("Engine"));  
    //StringArray == ["Hello","Unreal","Engine"]  
}

See Also

Help shape the future of Unreal Engine documentation! Tell us how we're doing so we can serve you better.
Take our survey
Dismiss