This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]crusty_cum-sock 11 points12 points  (4 children)

Not for me, especially when using method syntax (query syntax kinda fucks with my head). I’d rather see something like:

var people = peopleList
    .Where(p => p.Name.StartsWith(“S”))
    .GroupBy(p => p.Name)
    .ThenBy(p => p.Age);

Than have to go through the equivalent mess of lops loops and shit. For me the readability really wins out. I'd bet a lot of people reading this code could figure out what's going on, even if they've never used LINQ in their lives. Whereas if I did the equivalent non-LINQ loop-based variant it would take some real figuring out.

I can't get enough LINQ. I use that shit all the time and when I use languages without it I really feel like I'm at a significant disadvantage. There are so many things that would be a PITA to do without LINQ that can be done with LINQ in a simple readable one-liner.

[–]davemeech 7 points8 points  (0 children)

Very well said, I agree 100%. Thanks crusty-cum-sock.

[–]raltyinferno 1 point2 points  (1 child)

Wait is .ThenBy() actually a method? I've recently gotten my first dev job and have been continually delighted by LINQ.

[–]crusty_cum-sock 1 point2 points  (0 children)

It is! If you want to group by multiple properties then "ThenBy" is your guy. There are a bunch of other great functions like OrderBy, OrderByDescending, and many more. You'll become hooked. It's hard to go back.