How to remove item from struct array

I’ve being trying to remove a boolean from my struct array while iterating but, I couldn’t get it done. Some tip for a newbie?

The .h file

struct FMyStruct  

....   
UPROPERTY(...)  

bool MyBoo   

___  

class MyClass : public  

UPROPERTY(...)  

TArray &#60FMyStruct&#62 MyStruct

Then the .cpp

if (conditions met) { 
MyStruct.Remove(MyBoo);
}

VS2013 show me error like type name is not allowed

It looks like MyBoo is a bool type, while MyStruct is a TArray of FMyStruct-s, so you can’t remove a bool from it. Maybe it’s just a typing mistake, but you need to remove the struct instead of the bool. Also, you might want to avoid removing elements from a container while you’re iterating through it. You can avoid that for eg. by storing which elements you want to remove in a separate array, and then removing them

If you can’t resolve the issue, post more of your source, I can’t really tell what MyBoo is in your MyClass.cpp

1 Like