Do we need to watch out for nullptr from the array in the for loop

Is there any reason to set this up as below using if(Actor) to make sure there are no nullptrs?

for (AActor* Actor : Actors)
{
if (Actor)
{
FString ActorName = Actor->GetActorNameOrLabel();
UE_LOG(LogTemp, Display, TEXT(“Overlapping Actor: %s”), *ActorName);
}
}

I don’t think that would be possible. The array was just populated with the overlapping actors. That function isn’t going to be adding nullptrs to the array.

Thanks, make sense but I wasnt sure.

This topic was automatically closed 20 days after the last reply. New replies are no longer allowed.

Privacy & Terms