I find myself foreach-ing over IEnumerables a lot just so that I can return each result. Is there a way to compress something like this
foreach (var subSelector in subSelectors)
{
foreach (var node in FindSingle(context, subSelector))
yield return node;
}
To remove the inner foreach?
No, there isn’t, unless you completely replace every
yield returnwith a singlereturnstatement using LINQ.For example: