I had the following statement, which always returns null:
var addins = allocations.SelectMany(
set => set.locations.Any(q => q.IsMatch(level, count))
? (List<string>)set.addins : null
);
I changed it slightly, and now it works fine:
var addins = allocations.SelectMany(
set => set.locations.Any(q => q.IsMatch(level, count))
? set.addins : new List<string>()
);
My primary question: Why can't null serve as a return type from the ternary operator in this context of LINQ?
A secondary question: Is there a more clever way to formulate the above query (particularly if it eliminates the "new List()")?