Remove from Array, !works all the time?

If preserving the order does not matter:

bool AGameState::RemoveEquipment(AItemBase* Item)
{
  if (!Equipments.RemoveSwap(Item, false)) {
    print100s(...);
    return false;
  }
  OnEquipmentChanged_Ret.Broadcast(this, Item, false);
  return true;
}

Assuming it’s TArray<AItemBase*> and you don’t have duplicate pointers, it’s worth to use TArray<T>::RemoveSingleSwap instead.

2 Likes