Does this different implementation of ClearPaintings() work better or worse?

I was just wondering whether this different implementation is somehow worse/better than the one shown in the video:

My implementation:

void UPaintingGrid::ClearPaintings()
{
	if (!PaintingGrid) return;
	TArray <UWidget*> WidgetList = PaintingGrid->GetAllChildren();

	for (UWidget* Widget : WidgetList)
	{
		(Cast<USizeBox>(Widget))->ClearChildren();
	}


}

Video imlementation:

void UPaintingGrid::ClearPaintings()
{
	for (int32 i = 0; i < PaintingGrid->GetChildrenCount(); ++i)
	{
                USizeBox* CardContainer = Cast<USizeBox>(PaintingGrid->GetChildAt(i);
		if(!CardContainer) continue;

                CardContainer->ClearChildren();
	}


}

Perhaps it is just a style choice, but I think it is worth showing as it works just as good.

Either is fine. Basically the ClearChildren will be doing the same as your implementation.

Great! Thanks!

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

Privacy & Terms