|
|
|
|
|
by thecoffman
4672 days ago
|
|
Interesting - I found the lambda syntax of LINQ to be quite "Ruby like" someList.FindAll(i => i < 2)
.Select(i => i * 2)
.GroupBy(i => (i % 2) == 0 ? "even" : "odd")
Is about as close to Ruby's Enumerable as I've found in a mainstream/enterprise language (unless you include Scala). |
|
One really key difference with LINQ is that it doesn't produce arrays (or dictionaries, as in your example); it produces Enumerators, which you then have to do call toList() or toDictionary() on. That laziness is actually an awesome feature and my favorite thing about LINQ, because it can massively improve performance by shortcutting work and not creating intermediate arrays. You can even work on infinite sequences with it. Besides performance, it's just tastier. It's so great I actually wrote a Ruby library to imitate it: https://github.com/icambron/lazer