{ }Blueprint → C++

Unreal Engine 5 · Blueprint → C++

Array Length & Get Element in Unreal Engine 5 C++UE Docs

The Blueprint Length node maps to TArray::Num, the Get node maps to operator[] index access, and the final element is read with TArray::Last in Unreal Engine 5 C++.

Blueprint node & C++ equivalent

C++
int32 Count = Numbers.Num();
int32 First = Numbers[0];
int32 Last  = Numbers.Last();

What do the Length and Get nodes do?

Length returns how many elements an array currently holds, and Get returns the element stored at a given index. These are read-only queries on a TArray and do not modify the container.

The C++ equivalent

Numbers.Num() returns the element count as an int32. Square-bracket access like Numbers[0] returns a reference to the element at that index, matching the Blueprint Get node. Numbers.Last() returns the final element, which is equivalent to Numbers[Numbers.Num() - 1].

Avoiding out-of-bounds access

operator[] does not bounds-check in shipping builds, so reading Numbers[0] on an empty array is undefined behavior. Check Numbers.Num() > 0 first, or use Numbers.IsValidIndex(Index) before indexing. Last() also asserts the array is non-empty.

Frequently asked questions

How do you get the length of a TArray in UE5?+

Call MyArray.Num(). It returns the current number of elements as an int32.

How do you get the last element of a TArray?+

Call MyArray.Last(). It returns the final element; pass an offset like Last(1) to get the second-to-last.

Related Arrays & Containers nodes

View all Arrays & Containers nodes →