3 ms·
or use a language/environment that allows for trailing commas...
by shawndumas 13y ago
or use a language/environment that allows for trailing commas...
- cs648 13y agoThis really is the sensible solution.
- jumblesale 13y agoSeriously! Every language should support this. Not just for arrays but in argument lists too! Python does a good job here but I can't think of anything else which does.
- GotAnyMegadeth 13y agoPerl does
- Narretz 13y agoHint hint: PHP does this!
- dspillett 13y agoDepending on other syntax facets, that can create ambiguity. Does that trailing comma represent nothing (the end of the list) or an undefined/null/empty/whatever item (an extra item adding to the length of the list? Even if the meaning is completely unambiguous as far as the language is concerned, that doesn't necessarily make it intuitive to humans especially in a mixed language scenario.
- jbert 13y agoperl allows both trailing commas and also optional list-quoting which breaks on whitespace (commas unneeded): my @stuff = ( "foo", "bar", "baz", ); or: my @stuff = qw( foo bar baz ); or my @stuff = qw(foo bar baz); TIMTOWDI indeed...