logoalt Hacker News

CuriouslyCtoday at 12:42 PM1 replyview on HN

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.


Replies

mylifeandtimestoday at 5:02 PM

yes, 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.