davidgay 9 days ago

I'm of the opinion that

  var ageLookup = new Dictionary<AgeRange, List<Member>>();
  foreach (var member in members) {
    ageLookup.getOrCreate(member.AgeRange, List::new).add(member);
  }
is more readable in the long-term... (less predefined methods/concepts to learn).

1
n4r9 9 days ago

Where is `getOrCreate` defined? Is it a custom extension method? There's also a chance we're thinking in different languages. I was writing C#, yours looks a bit more like C++ maybe?

Readability incorporates familiarity but also conciseness. I suppose it depends what else is going on in the codebase. I have a database access class in one of my solutions where `ToLookup` is used 15 times; yes you have to learn the concept, but it's an inbuilt method and it's a massive benefit once you grok it.