ue4 foreach loop c++

// Assume you have a TArray of some elements, for example, integers.
TArray<int32> MyArray = {1, 2, 3, 4, 5};

// Use a for-each loop to iterate through each element in the array.
for (int32& Element : MyArray)
{
    // 'Element' is a reference to the current element in the array.

    // Perform operations on the current element.
    Element *= 2; // Multiply each element by 2, for example.
}

// The elements in 'MyArray' have been modified by the loop.
// Now 'MyArray' will be {2, 4, 6, 8, 10}.