Hi friends, I want to break the for-each-loop, not sure if i am doing right. look at bp example , i want the same way to break the loop.
//Remove any item from the array if this is not a weapon
for(int i = 1; i < 10; ++i)
{
for (auto& Array : ItemsIDArr)
{
if (Array.Type != EItemType::E_Weapon)
{
ItemsIDArr.Remove(Array);
}break;
}
}
and to remove index we use someArray.Remove(index); ??
BP Example:
If the break is under the if, the loop would stop, but always after looking only at the first element in the array ItemsIDArr. Also, this can happens even if you donβt remove the first element of the array
If ItemsIDArray is of type TArray, then you can use RemoveAt to remove an element in a specific position of the array.
For the compilation error, I think is probably related to the Remove method
ItemsIDArr.Remove(Array);
The Remove method, remove as many instances of the element Array from ItemsIDArr, and for that you need to compare to the elements in ItemsIDArr, using the operator β==β, and because is not defined there is an error.