4 ms·
I think the author is simply inexperienced in C#. Here's the right way to express his code: string.Join("\n", from elem in myList where el
by gecko 14y ago
I think the author is simply inexperienced in C#. Here's the right way to express his code:
string.Join("\n",
from elem in myList
where elem.Description != ""
select elem.Description);
Note how mind-numbingly close this is to the Python:
"\n".join(foo.description() for foo in mylist
if foo.description() != "")
I also think it's considerably easier to read than the foreach loop.
- deleted 14y ago[deleted]
- resurge 14y agoNote that this article is from 2006. Hence his using of C# 2.0 instead of a later version which includes Linq.
- kenko 14y agoLinq, which was inspired by ... Haskell! Would it be irresponsible to speculate that this article is directly responsible for the inclusion of Linq in C#? It would be irresponsible not to speculate!
- pjmlp 14y agoLINQ was introduced by Erik Meijer, an Haskell researcher working on .NET team. http://research.microsoft.com/en-us/um/people/emeijer/papers/es012-meijer.pdf http://research.microsoft.com/en-us/um/people/emeijer/papers...
- Ingaz 14y agoI've read this article in 2006. Even in this year it was obviously provocative. Now everybody knows that type inference, list comprehensions and lambda functions can reduce code. Even javers.