logoalt Hacker News

maratctoday at 12:23 PM5 repliesview on HN

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.


Replies

cyberrocktoday at 12:57 PM

I 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.

CuriouslyCtoday at 12:42 PM

The 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.

show 1 reply
9devtoday at 12:49 PM

You 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.

sligtoday at 12:36 PM

Must be nice to write code with the hopes that only intelligent people will read it.

inferniactoday at 4:18 PM

this is the most "i was dropped on my head as a baby" comment ive seen in a whiule