Reason #43 • February 12th, 2026

Trailing commas

Trailing commas are a fairly common feature in many programming languages, allowing developers to include a comma after the last item in a list, array, or object. This makes for a cleaner diff when adding new items to the list without having to worry about whether the previous item has a comma or not.

Ruby
names = [
  "Alice",
  "Bob",
  "Charlie",
]
# => ["Alice", "Bob", "Charlie"]

people = {
  "Alice" => 30,
  "Bob" => 25,
  "Charlie" => 35,
}
# => {"Alice"=>30, "Bob"=>25, "Charlie"=>35}
      
Visual Basic
Dim names As String() = {
  "Alice",
  "Bob",
  "Charlie"
}
' => {"Alice", "Bob", "Charlie"}

Dim people As Dictionary(Of String, Integer) = _
  New Dictionary(Of String, Integer) From {
  {"Alice", 30},
  {"Bob", 25},
  {"Charlie", 35}
}
' => {{"Alice", 30}, {"Bob", 25}, {"Charlie", 35}}
      

Some languages also allow trailing commas in function calls and definitions, which can be useful when dealing with long lists of parameters. In the statically typed camp of languages, this is supported only in the most recent ones like Rust and Go, while most dynamically typed languages have been quicker to embrace it.

Ruby
my_method(
  "Alice",
  "Bob",
  "Charlie",
)
      
Java
myMethod(
  "Alice",
  "Bob",
  "Charlie"
);
      

In Ruby, trailing commas can be used for everything except one thing: method definitions.

But lo and behold, Matz just announced today that he has been persuaded to change this. A draft pull request has already been created in Prism, the official Ruby parser.

So 🤞 it won't be long before we can use trailing commas consistently across all our Ruby codebases!