The MSDN gives this code example in the article on the Func Generic Delegate:
Func<String, int, bool> predicate = ( str, index) => str.Length == index;
String[] words = { "orange", "apple", "Article", "elephant", "star", "and" };
IEnumerable<String> aWords = words.Where(predicate).Select(str => str);
foreach (String word in aWords)
Console.WriteLine(word);
I understand what all this is doing. What I don't understand is the
Select(str => str)
bit. Surely that's not needed? If you leave it out and just have
IEnumerable<String> aWords = words.Where(predicate);
then you still get an IEnumerable back that contains the same results, and the code prints the same thing.
Am I missing something, or is the example misleading?