4 ms·
You just need to use auto properly. auto/var/val etc are best used when you can tell the type from the rvalue. var m = new HashMap<String, List<Pair<X, Y>
by vips7L 6y ago
You just need to use auto properly.
auto/var/val etc are best used when you can tell the type from the rvalue.
var m = new HashMap<String, List<Pair<X, Y>>>();
var m: Map<String, List<Pair<X, Y>>> = obj->someFunc();
All of the examples you have should be caught in linting or code review.
- grishka 6y ago> You just don't know how to use auto properly. I do. The problem is, others don't necessarily do. A good-in-my-world language makes it take more effort to write unreadable code than readable. Everyone seems to only be judging languages by the code you write yourself, totally oblivious to the fact that reading and understanding someone else's code, including in projects you don't influence, is also an important part of being a software developer.
- saagarjha 6y agoBelieve me, we've read a lot of code written by other people. There's a point where you read HashMap<Integer, ArrayList<String>> mapping = new HashMap<Integer, ArrayList<String>>(); enough times that you start to get tired of reading stuttering code, too.
- vips7L 6y agoBy your logic we shouldn't program because someone else MIGHT mess it up. Should we remove every feature that someone might misuse?