Let's have a method with the following signature:
A[] Translate(IEnumerable<B> bees)
I wonder if one of the following snippets would result in better execution, in any practical way.
if (bees == null || !bees.Any()) // Let's be super expressive
{
return null;
}
var translated = bees.Select(b => (...)).ToArray();
return translated; // Intermediate var so that I can debug easier
vs.
if (bees == null) // Let's be very expressive
{
return null;
}
var translated = bees.Select(b => (...)).ToArray();
return translated; // Intermediate var so that I can debug easier
vs.
return bees?.Select(b => (...)).ToArray();
Update 16/09: I've made the if
s return null, instead of a new array (which wasn't material to the spirit of my question)