3 ms·
Sorry, but I did not "forg[e]t a comma after the last item". I intentionally did not put a comma there. The list of the "important numbers" in my example is alr
by maratc 3mo ago
Sorry, but I did not "forg[e]t a comma after the last item". I intentionally did not put a comma there. The list of the "important numbers" in my example is already complete and perfect, and is not supposed to ever change. I wanted to emphasise this fact by specifically omitting the comma there, in the hope that intelligent people in the future would get this message exactly as I intended for it to be.
- slig 3mo agoMust be nice to write code with the hopes that only intelligent people will read it.
- CuriouslyC 3mo agoThe trailing comma rule is to avoid errors when devs copy/paste a line or dump a new line at the end. This matters particularly for arrays in languages with implicit string concatenation, where the missing comma won't trigger a compile error.
- mylifeandtimes 3mo agoyes, and isn't it funny that foo=[baz, bar,] returns a nice list of two items, but if you edit this down and miss the comma, foo=bar, is not a scalar. returning a tuple. So the trailing comma thing is a thing.
- 9dev 3mo agoYou will find that pretty much every rule we have in any possible context will have some exceptions that are justified under some conditions. Taking that as a reason to not have those rules in the first place seems like a logical fallacy that intelligent people should not make.
- cyberrock 3mo agoI think all of us have worked on code that other people thought was perfect or will never change. Personally I love this rule because it saves me from looking at one extra commit (adding the comma when the next value gets added) when I'm trying dig through line history.
- inferniac 3mo ago[flagged]
- tclancy 3mo agoYeah, but artfully dropped.