How to check multiple instances under: "if (::IsValid())"?

How to check these all instances in one line? if this is possible.

if (::IsValid(Material_A && Material_B && Material_C && Material_D))
      {
         //Logic
       }

I am getting an error, no instance of overload function "IsValid" is matched.

any help appreciated.

I can do like this, but this is not simple :smiley:

if (::IsValid(Material_A))
      {
             if (::IsValid(Material_B))
          {
                if (::IsValid(Material_C))
              {
                    if (::IsValid(Material_D))
                    {
                       //Logic
                     }
               }
           }
       }
bool YourClass::AreMaterialsValid(TArray<UMaterial*> Materials) {
  for (UMaterial* MaterialX : Materials) {
    if (!IsValid(MaterialX)) {
      return false;
    }
  }
  return true;
}
2 Likes

Thank You for the reply and helping me in my studies, I like the way the for Loop is implemented Thank You very much for the solution.

1 Like
if (IsValid(Material_A) && 
    IsValid(Material_B) && 
    IsValid(Material_C))
{
    // Logic
}
1 Like

Thank You for the reply and helping me in my studies.