Is there a tighter way to write this code?
foreach(var processName in processNames)
{
bool launched = launch(processName);
if (!launched)
{
return false;
}
}
return true;
I'm not sure what this kind of approach is called. But basically if any false the whole thing is false, otherwise it's true. The closest I can get is:
return !processNames.Any(process => !launch(process));
but I think the first approach is better because it's easier to understand.