5 ms·
An example where I disagree, and use 1-letter names daily: arrow functions in both Java and JS. `usersList.stream().forEach(u -> someSet.add(u))` It's immedia
by 12298765 8y ago
An example where I disagree, and use 1-letter names daily: arrow functions in both Java and JS.
`usersList.stream().forEach(u -> someSet.add(u))`
It's immediately obvious that u is a user in usersList. I realize that it's debatable if u is really more readable than spelling out user, but I prefer it, and I don't think anyone is going to be confused by it. If the chain does get really long, also, I will spell it out explicitly.
- irishsultan 8y agoShouldn't you be able to write that as `usersList.stream().forEach(someSet.add)` For Javascript at least that would work.
- leshow 8y agoI haven't written Java since like java 5, but I believe java 8 has syntax for this as well: `usersList.stream().forEach(someSet::add)`
- bpicolo 8y agoSure, for a lambda I think it’s arbitrary. For larger functions / classes it matters