Please don't do this :) Readable code is better than clever code!
Please don't do this :) Readable code is better than clever code!
var ageLookup = new Dictionary<AgeRange, List<Member>>();
foreach (var member in members) {
var ageRange = member.AgeRange;
if (ageLookup.ContainsKey(ageRange)) {
ageLookup[ageRange].Add(member);
} else {
ageLookup[ageRange] = new List<Member>();
ageLookup[ageRange].Add(member);
}
}
which could instead be: var ageLookup = members.ToLookup(m => m.AgeRange, m => m); 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).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.
I should also note that development style also depends on tools, so if your IDE makes inline functions more readable in it's display, it's fine to use concisely defined lambdas.
Readablity is a personal preference thing at some point after all.
I think what you're looking for is "x or 1"
At least with human-written clever code you can trust that somebody understood it at one point but the idea of trusting AI generated code that is "clever" makes my skin crawl
And was the code they were writing before they had an LLM any better?
My guess would be engineers who are "forced" to use AI, already mailed management it would be an error and are interviewing for their next company. Malicious compliance: vibe code those new features and let maintainability and security be a problem for next employees / consultants.
And I know it's intentional, but yes. Add some mindfulness to your implementation
Map["blah"] = fooIsTrue;
I do see your example in the wild sometimes. I've probably done it myself as well and never caught it.