by awelxtr · 3y ago · 0 comments
Why have I been 15 years programming in Java and I discovered this today?
On a more serious note, I prefer this kinds of posts to the traditional "Look at this shiny new thing" because without fundamental stuff the next big thing can't be built and normally this information makes you a slightly better programmer.
function foo(x,) {}
def foo(x,): pass
Before anyone questions why anyone would do this, it's for putting arguments (or array elements) on separate lines: function foo(
a,
b,
c,
) {}Also, last I remember in JS a trailing comma meant the creation of an extra array element that’s null so I became conditioned to only use trailing commas for separators in languages where it’s consistent and specified very explicitly like in HCL
Why? Because whenever there's a new value added, git diff shows single line change :)
"A trailing comma may appear after the last expression in an array initializer and is ignored"
https://titanium.cs.berkeley.edu/doc/java-langspec-1.0/10.do...