bbatsov/ruby-style-guide — Issue #76: Trailing Comma in Multi-Line Hashes & Arrays?
Author: benhamill
Created: 2012-02-22 05:38:52+00:00
State: open

I think I first ran into this style in Python, but I can't be sure. The idea is that in a multi-line liter Hash or Array, you leave a trailing comma on the final element, thus:

```ruby
DEFAULTS = {
page: 1,
per_page: 50,
sort_by: name,
}
```

The thinking is that it makes adding elements easier; it's easy to forget to add a trailing comma to the line before your new element, you don't clutter a diff by changing a line that, really, didn't have to do with your changes and you can copy/paste any line up or down the list without having to edit it.

Personally, I like this style, but I know others disagree. I thought I'd see what people thought here. So... thoughts?