* [ruby-core:110628] [Ruby master Feature#19107] Allow trailing comma in method signature
@ 2022-11-07 1:19 byroot (Jean Boussier)
2022-12-01 7:46 ` [ruby-core:111113] " matz (Yukihiro Matsumoto)
` (16 more replies)
0 siblings, 17 replies; 18+ messages in thread
From: byroot (Jean Boussier) @ 2022-11-07 1:19 UTC (permalink / raw)
To: ruby-core
Issue #19107 has been reported by byroot (Jean Boussier).
----------------------------------------
Feature #19107: Allow trailing comma in method signature
https://bugs.ruby-lang.org/issues/19107
* Author: byroot (Jean Boussier)
* Status: Open
* Priority: Normal
----------------------------------------
A popular style for multiline arrays, hashes or method calls, is to use trailing commas:
```ruby
array = [
1,
2,
3,
]
hash = {
foo: 1,
bar: 2,
baz: 3,
}
Some.method(
1,
2,
foo: 3,
)
```
The main reason to do this is to avoid unnecessary noise when adding one extra element:
```diff
diff --git a/foo.rb b/foo.rb
index b2689a7e4f..ddb7dc3552 100644
--- a/foo.rb
+++ b/foo.rb
@@ -1,4 +1,5 @@
Foo.bar(
foo: 1,
- bar: 2
+ bar: 2,
+ baz: 3
)
```
However, this pattern doesn't work with method declarations:
```ruby
def foo(bar:,) # syntax error, unexpected ')'
```
### Proposal
For consistency and convenience I propose to allow trailing commas in method declarations.
--
https://bugs.ruby-lang.org/
^ permalink raw reply related [flat|nested] 18+ messages in thread
* [ruby-core:111113] [Ruby master Feature#19107] Allow trailing comma in method signature
2022-11-07 1:19 [ruby-core:110628] [Ruby master Feature#19107] Allow trailing comma in method signature byroot (Jean Boussier)
@ 2022-12-01 7:46 ` matz (Yukihiro Matsumoto)
2022-12-01 8:51 ` [ruby-core:111122] " byroot (Jean Boussier)
` (15 subsequent siblings)
16 siblings, 0 replies; 18+ messages in thread
From: matz (Yukihiro Matsumoto) @ 2022-12-01 7:46 UTC (permalink / raw)
To: ruby-core
Issue #19107 has been updated by matz (Yukihiro Matsumoto).
I don't care for consistency here (since formal arguments and actual arguments are different).
I am not sure for convenience. Compare to actual arguments, there's less chance to rewrite/update formal arguments.
Is there an actual case where this proposal is convenient?
Matz.
----------------------------------------
Feature #19107: Allow trailing comma in method signature
https://bugs.ruby-lang.org/issues/19107#change-100385
* Author: byroot (Jean Boussier)
* Status: Open
* Priority: Normal
----------------------------------------
A popular style for multiline arrays, hashes or method calls, is to use trailing commas:
```ruby
array = [
1,
2,
3,
]
hash = {
foo: 1,
bar: 2,
baz: 3,
}
Some.method(
1,
2,
foo: 3,
)
```
The main reason to do this is to avoid unnecessary noise when adding one extra element:
```diff
diff --git a/foo.rb b/foo.rb
index b2689a7e4f..ddb7dc3552 100644
--- a/foo.rb
+++ b/foo.rb
@@ -1,4 +1,5 @@
Foo.bar(
foo: 1,
- bar: 2
+ bar: 2,
+ baz: 3
)
```
However, this pattern doesn't work with method declarations:
```ruby
def foo(bar:,) # syntax error, unexpected ')'
```
### Proposal
For consistency and convenience I propose to allow trailing commas in method declarations.
--
https://bugs.ruby-lang.org/
______________________________________________
ruby-core mailing list -- ruby-core@ml.ruby-lang.org
To unsubscribe send an email to ruby-core-leave@ml.ruby-lang.org
ruby-core info -- https://ml.ruby-lang.org/mailman3/postorius/lists/ruby-core.ml.ruby-lang.org/
^ permalink raw reply related [flat|nested] 18+ messages in thread
* [ruby-core:111122] [Ruby master Feature#19107] Allow trailing comma in method signature
2022-11-07 1:19 [ruby-core:110628] [Ruby master Feature#19107] Allow trailing comma in method signature byroot (Jean Boussier)
2022-12-01 7:46 ` [ruby-core:111113] " matz (Yukihiro Matsumoto)
@ 2022-12-01 8:51 ` byroot (Jean Boussier)
2023-02-13 6:20 ` [ruby-core:112393] " rubyFeedback (robert heiler) via ruby-core
` (14 subsequent siblings)
16 siblings, 0 replies; 18+ messages in thread
From: byroot (Jean Boussier) @ 2022-12-01 8:51 UTC (permalink / raw)
To: ruby-core
Issue #19107 has been updated by byroot (Jean Boussier).
> Is there an actual case where this proposal is convenient?
Yes, when replacing old APIs that took an "option hash" by explicit keyword arguments, it tend to create very large signature.
The last example I have in mind is `redis-client`: https://github.com/redis-rb/redis-client/blob/dcfe43abb83597bee129537464e20805658bf7a9/lib/redis_client/config.rb#L21-L41
```ruby
def initialize(
username: nil,
password: nil,
db: nil,
id: nil,
timeout: DEFAULT_TIMEOUT,
read_timeout: timeout,
write_timeout: timeout,
connect_timeout: timeout,
ssl: nil,
custom: {},
ssl_params: nil,
driver: nil,
protocol: 3,
client_implementation: RedisClient,
command_builder: CommandBuilder,
inherit_socket: false,
reconnect_attempts: false,
middlewares: false,
circuit_breaker: nil
)
```
When adding a new argument, it cause these annoying diffs:
```diff
diff --git a/lib/redis_client/config.rb b/lib/redis_client/config.rb
index fc74367..6412171 100644
--- a/lib/redis_client/config.rb
+++ b/lib/redis_client/config.rb
@@ -36,7 +36,8 @@ class RedisClient
command_builder: CommandBuilder,
inherit_socket: false,
reconnect_attempts: false,
- middlewares: false
+ middlewares: false,
+ circuit_breaker: nil
)
@username = username
@password = password
```
Also this inconsistency is the reason why some popular styleguides reverted back to not using trailing comma for multi-line enumerations:
- https://github.com/testdouble/standard/pull/453#issuecomment-1234208705
- https://github.com/fables-tales/rubyfmt/issues/154
----------------------------------------
Feature #19107: Allow trailing comma in method signature
https://bugs.ruby-lang.org/issues/19107#change-100396
* Author: byroot (Jean Boussier)
* Status: Open
* Priority: Normal
----------------------------------------
A popular style for multiline arrays, hashes or method calls, is to use trailing commas:
```ruby
array = [
1,
2,
3,
]
hash = {
foo: 1,
bar: 2,
baz: 3,
}
Some.method(
1,
2,
foo: 3,
)
```
The main reason to do this is to avoid unnecessary noise when adding one extra element:
```diff
diff --git a/foo.rb b/foo.rb
index b2689a7e4f..ddb7dc3552 100644
--- a/foo.rb
+++ b/foo.rb
@@ -1,4 +1,5 @@
Foo.bar(
foo: 1,
- bar: 2
+ bar: 2,
+ baz: 3
)
```
However, this pattern doesn't work with method declarations:
```ruby
def foo(bar:,) # syntax error, unexpected ')'
```
### Proposal
For consistency and convenience I propose to allow trailing commas in method declarations.
--
https://bugs.ruby-lang.org/
______________________________________________
ruby-core mailing list -- ruby-core@ml.ruby-lang.org
To unsubscribe send an email to ruby-core-leave@ml.ruby-lang.org
ruby-core info -- https://ml.ruby-lang.org/mailman3/postorius/lists/ruby-core.ml.ruby-lang.org/
^ permalink raw reply related [flat|nested] 18+ messages in thread
* [ruby-core:112393] [Ruby master Feature#19107] Allow trailing comma in method signature
2022-11-07 1:19 [ruby-core:110628] [Ruby master Feature#19107] Allow trailing comma in method signature byroot (Jean Boussier)
2022-12-01 7:46 ` [ruby-core:111113] " matz (Yukihiro Matsumoto)
2022-12-01 8:51 ` [ruby-core:111122] " byroot (Jean Boussier)
@ 2023-02-13 6:20 ` rubyFeedback (robert heiler) via ruby-core
2023-02-13 6:43 ` [ruby-core:112394] " k0kubun (Takashi Kokubun) via ruby-core
` (13 subsequent siblings)
16 siblings, 0 replies; 18+ messages in thread
From: rubyFeedback (robert heiler) via ruby-core @ 2023-02-13 6:20 UTC (permalink / raw)
To: ruby-core; +Cc: rubyFeedback (robert heiler)
Issue #19107 has been updated by rubyFeedback (robert heiler).
To me the ',' there looks rather awkward. Then again the
first time I saw def(foo:) I was also confused.
----------------------------------------
Feature #19107: Allow trailing comma in method signature
https://bugs.ruby-lang.org/issues/19107#change-101835
* Author: byroot (Jean Boussier)
* Status: Open
* Priority: Normal
----------------------------------------
A popular style for multiline arrays, hashes or method calls, is to use trailing commas:
```ruby
array = [
1,
2,
3,
]
hash = {
foo: 1,
bar: 2,
baz: 3,
}
Some.method(
1,
2,
foo: 3,
)
```
The main reason to do this is to avoid unnecessary noise when adding one extra element:
```diff
diff --git a/foo.rb b/foo.rb
index b2689a7e4f..ddb7dc3552 100644
--- a/foo.rb
+++ b/foo.rb
@@ -1,4 +1,5 @@
Foo.bar(
foo: 1,
- bar: 2
+ bar: 2,
+ baz: 3
)
```
However, this pattern doesn't work with method declarations:
```ruby
def foo(bar:,) # syntax error, unexpected ')'
```
### Proposal
For consistency and convenience I propose to allow trailing commas in method declarations.
--
https://bugs.ruby-lang.org/
______________________________________________
ruby-core mailing list -- ruby-core@ml.ruby-lang.org
To unsubscribe send an email to ruby-core-leave@ml.ruby-lang.org
ruby-core info -- https://ml.ruby-lang.org/mailman3/postorius/lists/ruby-core.ml.ruby-lang.org/
^ permalink raw reply related [flat|nested] 18+ messages in thread
* [ruby-core:112394] [Ruby master Feature#19107] Allow trailing comma in method signature
2022-11-07 1:19 [ruby-core:110628] [Ruby master Feature#19107] Allow trailing comma in method signature byroot (Jean Boussier)
` (2 preceding siblings ...)
2023-02-13 6:20 ` [ruby-core:112393] " rubyFeedback (robert heiler) via ruby-core
@ 2023-02-13 6:43 ` k0kubun (Takashi Kokubun) via ruby-core
2026-01-14 1:09 ` [ruby-core:124520] [Ruby " k0kubun (Takashi Kokubun) via ruby-core
` (12 subsequent siblings)
16 siblings, 0 replies; 18+ messages in thread
From: k0kubun (Takashi Kokubun) via ruby-core @ 2023-02-13 6:43 UTC (permalink / raw)
To: ruby-core; +Cc: k0kubun (Takashi Kokubun)
Issue #19107 has been updated by k0kubun (Takashi Kokubun).
I second this proposal.
`def foo(bar:,)` doesn't seem like a real use-case, but when a method has so many arguments and I declare arguments in multiple lines, I would love to put a trailing comma to minimize future git diff and make reviewing the Ruby code easier.
For example, this is today's `ERB#initialize`:
```rb
def initialize(str, safe_level=NOT_GIVEN, legacy_trim_mode=NOT_GIVEN, legacy_eoutvar=NOT_GIVEN, trim_mode: nil, eoutvar: '_erbout')
# ...
end
```
This line is still short enough to fit on my screen, however, if we were to add another option, e.g. `filename`, I would write:
```rb
def initialize(
str,
safe_level=NOT_GIVEN,
legacy_trim_mode=NOT_GIVEN,
legacy_eoutvar=NOT_GIVEN,
trim_mode: nil,
eoutvar: '_erbout',
filename: nil,
)
# ...
end
```
which doesn't seem awkward to me. But this is a SyntaxError today. If you don't put a `,` there, you'll see a diff on `filename` when you add another option after that even if the patch is not related to `filename`, which would make me frustrated when reviewing that code.
----------------------------------------
Feature #19107: Allow trailing comma in method signature
https://bugs.ruby-lang.org/issues/19107#change-101836
* Author: byroot (Jean Boussier)
* Status: Open
* Priority: Normal
----------------------------------------
A popular style for multiline arrays, hashes or method calls, is to use trailing commas:
```ruby
array = [
1,
2,
3,
]
hash = {
foo: 1,
bar: 2,
baz: 3,
}
Some.method(
1,
2,
foo: 3,
)
```
The main reason to do this is to avoid unnecessary noise when adding one extra element:
```diff
diff --git a/foo.rb b/foo.rb
index b2689a7e4f..ddb7dc3552 100644
--- a/foo.rb
+++ b/foo.rb
@@ -1,4 +1,5 @@
Foo.bar(
foo: 1,
- bar: 2
+ bar: 2,
+ baz: 3
)
```
However, this pattern doesn't work with method declarations:
```ruby
def foo(bar:,) # syntax error, unexpected ')'
```
### Proposal
For consistency and convenience I propose to allow trailing commas in method declarations.
--
https://bugs.ruby-lang.org/
______________________________________________
ruby-core mailing list -- ruby-core@ml.ruby-lang.org
To unsubscribe send an email to ruby-core-leave@ml.ruby-lang.org
ruby-core info -- https://ml.ruby-lang.org/mailman3/postorius/lists/ruby-core.ml.ruby-lang.org/
^ permalink raw reply related [flat|nested] 18+ messages in thread
* [ruby-core:124520] [Ruby Feature#19107] Allow trailing comma in method signature
2022-11-07 1:19 [ruby-core:110628] [Ruby master Feature#19107] Allow trailing comma in method signature byroot (Jean Boussier)
` (3 preceding siblings ...)
2023-02-13 6:43 ` [ruby-core:112394] " k0kubun (Takashi Kokubun) via ruby-core
@ 2026-01-14 1:09 ` k0kubun (Takashi Kokubun) via ruby-core
2026-02-12 4:12 ` [ruby-core:124775] " matz (Yukihiro Matsumoto) via ruby-core
` (11 subsequent siblings)
16 siblings, 0 replies; 18+ messages in thread
From: k0kubun (Takashi Kokubun) via ruby-core @ 2026-01-14 1:09 UTC (permalink / raw)
To: ruby-core; +Cc: k0kubun (Takashi Kokubun)
Issue #19107 has been updated by k0kubun (Takashi Kokubun).
Can we reconsider this? To Matz' question (see also: [DevMeeting-2022-12-01](https://github.com/ruby/dev-meeting-log/blob/master/2022/DevMeeting-2022-12-01.md#feature-19107-allow-trailing-comma-in-method-signature-byroot)):
> Is there an actual case where this proposal is convenient?
@byroot and I have shown real-world use cases in open-source repositories. In closed-source applications, e.g. at Shopify, it's common to see methods that have much more (optional, keyword) arguments, which would benefit from this syntax.
At the Ruby Release 30th Party, in Koichi's presentation (which Matz missed), @byroot mentioned this feature as one of his wishes for the future of Ruby. IIRC, @shyouhei said this was rejected last time because this would cause a conflict in the syntax when parentheses are omitted. However, somebody else (I forgot, maybe @yui-knk or @nobu?) said some discrepancy between method definitions with parens and ones without parens already exist, and I'm sure we want this feature only when a method is defined with parens. So we shouldn't need to reject this for the previous reason.
So, can we revisit this? Now that `it` is in, this is my most-wanted feature in Ruby now. I respect that there are people who don't put parens in method definitions (and therefore have no interest in this feature) or think trailing commas are awkward, but I'd like to remind you that there are other people who put parens in method definitions and want to minimize the git diff when a new parameter is added at the end of such method definitions with many parameters.
----------------------------------------
Feature #19107: Allow trailing comma in method signature
https://bugs.ruby-lang.org/issues/19107#change-116080
* Author: byroot (Jean Boussier)
* Status: Open
----------------------------------------
A popular style for multiline arrays, hashes or method calls, is to use trailing commas:
```ruby
array = [
1,
2,
3,
]
hash = {
foo: 1,
bar: 2,
baz: 3,
}
Some.method(
1,
2,
foo: 3,
)
```
The main reason to do this is to avoid unnecessary noise when adding one extra element:
```diff
diff --git a/foo.rb b/foo.rb
index b2689a7e4f..ddb7dc3552 100644
--- a/foo.rb
+++ b/foo.rb
@@ -1,4 +1,5 @@
Foo.bar(
foo: 1,
- bar: 2
+ bar: 2,
+ baz: 3
)
```
However, this pattern doesn't work with method declarations:
```ruby
def foo(bar:,) # syntax error, unexpected ')'
```
### Proposal
For consistency and convenience I propose to allow trailing commas in method declarations.
--
https://bugs.ruby-lang.org/
______________________________________________
ruby-core mailing list -- ruby-core@ml.ruby-lang.org
To unsubscribe send an email to ruby-core-leave@ml.ruby-lang.org
ruby-core info -- https://ml.ruby-lang.org/mailman3/lists/ruby-core.ml.ruby-lang.org/
^ permalink raw reply related [flat|nested] 18+ messages in thread
* [ruby-core:124775] [Ruby Feature#19107] Allow trailing comma in method signature
2022-11-07 1:19 [ruby-core:110628] [Ruby master Feature#19107] Allow trailing comma in method signature byroot (Jean Boussier)
` (4 preceding siblings ...)
2026-01-14 1:09 ` [ruby-core:124520] [Ruby " k0kubun (Takashi Kokubun) via ruby-core
@ 2026-02-12 4:12 ` matz (Yukihiro Matsumoto) via ruby-core
2026-02-12 7:53 ` [ruby-core:124781] " Earlopain (Earlopain _) via ruby-core
` (10 subsequent siblings)
16 siblings, 0 replies; 18+ messages in thread
From: matz (Yukihiro Matsumoto) via ruby-core @ 2026-02-12 4:12 UTC (permalink / raw)
To: ruby-core; +Cc: matz (Yukihiro Matsumoto)
Issue #19107 has been updated by matz (Yukihiro Matsumoto).
I've been persuaded. I'll accept it. It's better not to allow commas to appear after certain points (like after `&block` and `...`).
Matz.
----------------------------------------
Feature #19107: Allow trailing comma in method signature
https://bugs.ruby-lang.org/issues/19107#change-116386
* Author: byroot (Jean Boussier)
* Status: Open
----------------------------------------
A popular style for multiline arrays, hashes or method calls, is to use trailing commas:
```ruby
array = [
1,
2,
3,
]
hash = {
foo: 1,
bar: 2,
baz: 3,
}
Some.method(
1,
2,
foo: 3,
)
```
The main reason to do this is to avoid unnecessary noise when adding one extra element:
```diff
diff --git a/foo.rb b/foo.rb
index b2689a7e4f..ddb7dc3552 100644
--- a/foo.rb
+++ b/foo.rb
@@ -1,4 +1,5 @@
Foo.bar(
foo: 1,
- bar: 2
+ bar: 2,
+ baz: 3
)
```
However, this pattern doesn't work with method declarations:
```ruby
def foo(bar:,) # syntax error, unexpected ')'
```
### Proposal
For consistency and convenience I propose to allow trailing commas in method declarations.
--
https://bugs.ruby-lang.org/
______________________________________________
ruby-core mailing list -- ruby-core@ml.ruby-lang.org
To unsubscribe send an email to ruby-core-leave@ml.ruby-lang.org
ruby-core info -- https://ml.ruby-lang.org/mailman3/lists/ruby-core.ml.ruby-lang.org/
^ permalink raw reply related [flat|nested] 18+ messages in thread
* [ruby-core:124781] [Ruby Feature#19107] Allow trailing comma in method signature
2022-11-07 1:19 [ruby-core:110628] [Ruby master Feature#19107] Allow trailing comma in method signature byroot (Jean Boussier)
` (5 preceding siblings ...)
2026-02-12 4:12 ` [ruby-core:124775] " matz (Yukihiro Matsumoto) via ruby-core
@ 2026-02-12 7:53 ` Earlopain (Earlopain _) via ruby-core
2026-02-12 7:59 ` [ruby-core:124782] " byroot (Jean Boussier) via ruby-core
` (9 subsequent siblings)
16 siblings, 0 replies; 18+ messages in thread
From: Earlopain (Earlopain _) via ruby-core @ 2026-02-12 7:53 UTC (permalink / raw)
To: ruby-core; +Cc: Earlopain (Earlopain _)
Issue #19107 has been updated by Earlopain (Earlopain _).
Assignee set to prism
To clarify, to we also accept `-> (a, b, ) {}`? I would say yes but am going to assume no for now.
----------------------------------------
Feature #19107: Allow trailing comma in method signature
https://bugs.ruby-lang.org/issues/19107#change-116392
* Author: byroot (Jean Boussier)
* Status: Open
* Assignee: prism
----------------------------------------
A popular style for multiline arrays, hashes or method calls, is to use trailing commas:
```ruby
array = [
1,
2,
3,
]
hash = {
foo: 1,
bar: 2,
baz: 3,
}
Some.method(
1,
2,
foo: 3,
)
```
The main reason to do this is to avoid unnecessary noise when adding one extra element:
```diff
diff --git a/foo.rb b/foo.rb
index b2689a7e4f..ddb7dc3552 100644
--- a/foo.rb
+++ b/foo.rb
@@ -1,4 +1,5 @@
Foo.bar(
foo: 1,
- bar: 2
+ bar: 2,
+ baz: 3
)
```
However, this pattern doesn't work with method declarations:
```ruby
def foo(bar:,) # syntax error, unexpected ')'
```
### Proposal
For consistency and convenience I propose to allow trailing commas in method declarations.
--
https://bugs.ruby-lang.org/
______________________________________________
ruby-core mailing list -- ruby-core@ml.ruby-lang.org
To unsubscribe send an email to ruby-core-leave@ml.ruby-lang.org
ruby-core info -- https://ml.ruby-lang.org/mailman3/lists/ruby-core.ml.ruby-lang.org/
^ permalink raw reply related [flat|nested] 18+ messages in thread
* [ruby-core:124782] [Ruby Feature#19107] Allow trailing comma in method signature
2022-11-07 1:19 [ruby-core:110628] [Ruby master Feature#19107] Allow trailing comma in method signature byroot (Jean Boussier)
` (6 preceding siblings ...)
2026-02-12 7:53 ` [ruby-core:124781] " Earlopain (Earlopain _) via ruby-core
@ 2026-02-12 7:59 ` byroot (Jean Boussier) via ruby-core
2026-02-12 7:59 ` [ruby-core:124783] " byroot (Jean Boussier) via ruby-core
` (8 subsequent siblings)
16 siblings, 0 replies; 18+ messages in thread
From: byroot (Jean Boussier) via ruby-core @ 2026-02-12 7:59 UTC (permalink / raw)
To: ruby-core; +Cc: byroot (Jean Boussier)
Issue #19107 has been updated by byroot (Jean Boussier).
>From the meeting logs:
> nobu: carriage return is required? def `foo(a,)` seems strange.
> matz: no problem to allow it.
So yes.
----------------------------------------
Feature #19107: Allow trailing comma in method signature
https://bugs.ruby-lang.org/issues/19107#change-116393
* Author: byroot (Jean Boussier)
* Status: Open
* Assignee: prism
----------------------------------------
A popular style for multiline arrays, hashes or method calls, is to use trailing commas:
```ruby
array = [
1,
2,
3,
]
hash = {
foo: 1,
bar: 2,
baz: 3,
}
Some.method(
1,
2,
foo: 3,
)
```
The main reason to do this is to avoid unnecessary noise when adding one extra element:
```diff
diff --git a/foo.rb b/foo.rb
index b2689a7e4f..ddb7dc3552 100644
--- a/foo.rb
+++ b/foo.rb
@@ -1,4 +1,5 @@
Foo.bar(
foo: 1,
- bar: 2
+ bar: 2,
+ baz: 3
)
```
However, this pattern doesn't work with method declarations:
```ruby
def foo(bar:,) # syntax error, unexpected ')'
```
### Proposal
For consistency and convenience I propose to allow trailing commas in method declarations.
--
https://bugs.ruby-lang.org/
______________________________________________
ruby-core mailing list -- ruby-core@ml.ruby-lang.org
To unsubscribe send an email to ruby-core-leave@ml.ruby-lang.org
ruby-core info -- https://ml.ruby-lang.org/mailman3/lists/ruby-core.ml.ruby-lang.org/
^ permalink raw reply related [flat|nested] 18+ messages in thread
* [ruby-core:124783] [Ruby Feature#19107] Allow trailing comma in method signature
2022-11-07 1:19 [ruby-core:110628] [Ruby master Feature#19107] Allow trailing comma in method signature byroot (Jean Boussier)
` (7 preceding siblings ...)
2026-02-12 7:59 ` [ruby-core:124782] " byroot (Jean Boussier) via ruby-core
@ 2026-02-12 7:59 ` byroot (Jean Boussier) via ruby-core
2026-02-12 8:51 ` [ruby-core:124789] " Earlopain (Earlopain _) via ruby-core
` (7 subsequent siblings)
16 siblings, 0 replies; 18+ messages in thread
From: byroot (Jean Boussier) via ruby-core @ 2026-02-12 7:59 UTC (permalink / raw)
To: ruby-core; +Cc: byroot (Jean Boussier)
Issue #19107 has been updated by byroot (Jean Boussier).
Note that Matz also pointed out that `(...,)` and `(&block,)` should still not be allowed.
----------------------------------------
Feature #19107: Allow trailing comma in method signature
https://bugs.ruby-lang.org/issues/19107#change-116394
* Author: byroot (Jean Boussier)
* Status: Open
* Assignee: prism
----------------------------------------
A popular style for multiline arrays, hashes or method calls, is to use trailing commas:
```ruby
array = [
1,
2,
3,
]
hash = {
foo: 1,
bar: 2,
baz: 3,
}
Some.method(
1,
2,
foo: 3,
)
```
The main reason to do this is to avoid unnecessary noise when adding one extra element:
```diff
diff --git a/foo.rb b/foo.rb
index b2689a7e4f..ddb7dc3552 100644
--- a/foo.rb
+++ b/foo.rb
@@ -1,4 +1,5 @@
Foo.bar(
foo: 1,
- bar: 2
+ bar: 2,
+ baz: 3
)
```
However, this pattern doesn't work with method declarations:
```ruby
def foo(bar:,) # syntax error, unexpected ')'
```
### Proposal
For consistency and convenience I propose to allow trailing commas in method declarations.
--
https://bugs.ruby-lang.org/
______________________________________________
ruby-core mailing list -- ruby-core@ml.ruby-lang.org
To unsubscribe send an email to ruby-core-leave@ml.ruby-lang.org
ruby-core info -- https://ml.ruby-lang.org/mailman3/lists/ruby-core.ml.ruby-lang.org/
^ permalink raw reply related [flat|nested] 18+ messages in thread
* [ruby-core:124789] [Ruby Feature#19107] Allow trailing comma in method signature
2022-11-07 1:19 [ruby-core:110628] [Ruby master Feature#19107] Allow trailing comma in method signature byroot (Jean Boussier)
` (8 preceding siblings ...)
2026-02-12 7:59 ` [ruby-core:124783] " byroot (Jean Boussier) via ruby-core
@ 2026-02-12 8:51 ` Earlopain (Earlopain _) via ruby-core
2026-02-12 8:54 ` [ruby-core:124790] " byroot (Jean Boussier) via ruby-core
` (6 subsequent siblings)
16 siblings, 0 replies; 18+ messages in thread
From: Earlopain (Earlopain _) via ruby-core @ 2026-02-12 8:51 UTC (permalink / raw)
To: ruby-core; +Cc: Earlopain (Earlopain _)
Issue #19107 has been updated by Earlopain (Earlopain _).
Ah, sorry. That was about lambdas, not newlines.
I'll wait until the logs are published and see if they came up. They were never mentioned explicitly but it should be very easy for prism to allow them if that changes.
----------------------------------------
Feature #19107: Allow trailing comma in method signature
https://bugs.ruby-lang.org/issues/19107#change-116401
* Author: byroot (Jean Boussier)
* Status: Open
* Assignee: prism
----------------------------------------
A popular style for multiline arrays, hashes or method calls, is to use trailing commas:
```ruby
array = [
1,
2,
3,
]
hash = {
foo: 1,
bar: 2,
baz: 3,
}
Some.method(
1,
2,
foo: 3,
)
```
The main reason to do this is to avoid unnecessary noise when adding one extra element:
```diff
diff --git a/foo.rb b/foo.rb
index b2689a7e4f..ddb7dc3552 100644
--- a/foo.rb
+++ b/foo.rb
@@ -1,4 +1,5 @@
Foo.bar(
foo: 1,
- bar: 2
+ bar: 2,
+ baz: 3
)
```
However, this pattern doesn't work with method declarations:
```ruby
def foo(bar:,) # syntax error, unexpected ')'
```
### Proposal
For consistency and convenience I propose to allow trailing commas in method declarations.
--
https://bugs.ruby-lang.org/
______________________________________________
ruby-core mailing list -- ruby-core@ml.ruby-lang.org
To unsubscribe send an email to ruby-core-leave@ml.ruby-lang.org
ruby-core info -- https://ml.ruby-lang.org/mailman3/lists/ruby-core.ml.ruby-lang.org/
^ permalink raw reply related [flat|nested] 18+ messages in thread
* [ruby-core:124790] [Ruby Feature#19107] Allow trailing comma in method signature
2022-11-07 1:19 [ruby-core:110628] [Ruby master Feature#19107] Allow trailing comma in method signature byroot (Jean Boussier)
` (9 preceding siblings ...)
2026-02-12 8:51 ` [ruby-core:124789] " Earlopain (Earlopain _) via ruby-core
@ 2026-02-12 8:54 ` byroot (Jean Boussier) via ruby-core
2026-02-12 10:52 ` [ruby-core:124793] " Earlopain (Earlopain _) via ruby-core
` (5 subsequent siblings)
16 siblings, 0 replies; 18+ messages in thread
From: byroot (Jean Boussier) via ruby-core @ 2026-02-12 8:54 UTC (permalink / raw)
To: ruby-core; +Cc: byroot (Jean Boussier)
Issue #19107 has been updated by byroot (Jean Boussier).
They weren't mentioned, but since they use `()` like methods, I think it is implied it works for them too?
----------------------------------------
Feature #19107: Allow trailing comma in method signature
https://bugs.ruby-lang.org/issues/19107#change-116402
* Author: byroot (Jean Boussier)
* Status: Open
* Assignee: prism
----------------------------------------
A popular style for multiline arrays, hashes or method calls, is to use trailing commas:
```ruby
array = [
1,
2,
3,
]
hash = {
foo: 1,
bar: 2,
baz: 3,
}
Some.method(
1,
2,
foo: 3,
)
```
The main reason to do this is to avoid unnecessary noise when adding one extra element:
```diff
diff --git a/foo.rb b/foo.rb
index b2689a7e4f..ddb7dc3552 100644
--- a/foo.rb
+++ b/foo.rb
@@ -1,4 +1,5 @@
Foo.bar(
foo: 1,
- bar: 2
+ bar: 2,
+ baz: 3
)
```
However, this pattern doesn't work with method declarations:
```ruby
def foo(bar:,) # syntax error, unexpected ')'
```
### Proposal
For consistency and convenience I propose to allow trailing commas in method declarations.
--
https://bugs.ruby-lang.org/
______________________________________________
ruby-core mailing list -- ruby-core@ml.ruby-lang.org
To unsubscribe send an email to ruby-core-leave@ml.ruby-lang.org
ruby-core info -- https://ml.ruby-lang.org/mailman3/lists/ruby-core.ml.ruby-lang.org/
^ permalink raw reply related [flat|nested] 18+ messages in thread
* [ruby-core:124793] [Ruby Feature#19107] Allow trailing comma in method signature
2022-11-07 1:19 [ruby-core:110628] [Ruby master Feature#19107] Allow trailing comma in method signature byroot (Jean Boussier)
` (10 preceding siblings ...)
2026-02-12 8:54 ` [ruby-core:124790] " byroot (Jean Boussier) via ruby-core
@ 2026-02-12 10:52 ` Earlopain (Earlopain _) via ruby-core
2026-02-12 11:04 ` [ruby-core:124794] " byroot (Jean Boussier) via ruby-core
` (4 subsequent siblings)
16 siblings, 0 replies; 18+ messages in thread
From: Earlopain (Earlopain _) via ruby-core @ 2026-02-12 10:52 UTC (permalink / raw)
To: ruby-core; +Cc: Earlopain (Earlopain _)
Issue #19107 has been updated by Earlopain (Earlopain _).
Hm, not so sure about lambdas actually. Consider `|foo,|` block arguments, which causes the block to accept any number of positional arguments. I think a lambda should behave the same.
If it is so, the usefulness is pretty limited since it doesn't work with the way the issue is about. Either way, I think it would need to be discussed first since I'm not 100% on the desired behaviour.
----------------------------------------
Feature #19107: Allow trailing comma in method signature
https://bugs.ruby-lang.org/issues/19107#change-116405
* Author: byroot (Jean Boussier)
* Status: Open
* Assignee: prism
----------------------------------------
A popular style for multiline arrays, hashes or method calls, is to use trailing commas:
```ruby
array = [
1,
2,
3,
]
hash = {
foo: 1,
bar: 2,
baz: 3,
}
Some.method(
1,
2,
foo: 3,
)
```
The main reason to do this is to avoid unnecessary noise when adding one extra element:
```diff
diff --git a/foo.rb b/foo.rb
index b2689a7e4f..ddb7dc3552 100644
--- a/foo.rb
+++ b/foo.rb
@@ -1,4 +1,5 @@
Foo.bar(
foo: 1,
- bar: 2
+ bar: 2,
+ baz: 3
)
```
However, this pattern doesn't work with method declarations:
```ruby
def foo(bar:,) # syntax error, unexpected ')'
```
### Proposal
For consistency and convenience I propose to allow trailing commas in method declarations.
--
https://bugs.ruby-lang.org/
______________________________________________
ruby-core mailing list -- ruby-core@ml.ruby-lang.org
To unsubscribe send an email to ruby-core-leave@ml.ruby-lang.org
ruby-core info -- https://ml.ruby-lang.org/mailman3/lists/ruby-core.ml.ruby-lang.org/
^ permalink raw reply related [flat|nested] 18+ messages in thread
* [ruby-core:124794] [Ruby Feature#19107] Allow trailing comma in method signature
2022-11-07 1:19 [ruby-core:110628] [Ruby master Feature#19107] Allow trailing comma in method signature byroot (Jean Boussier)
` (11 preceding siblings ...)
2026-02-12 10:52 ` [ruby-core:124793] " Earlopain (Earlopain _) via ruby-core
@ 2026-02-12 11:04 ` byroot (Jean Boussier) via ruby-core
2026-02-12 11:40 ` [ruby-core:124795] " Earlopain (Earlopain _) via ruby-core
` (3 subsequent siblings)
16 siblings, 0 replies; 18+ messages in thread
From: byroot (Jean Boussier) via ruby-core @ 2026-02-12 11:04 UTC (permalink / raw)
To: ruby-core; +Cc: byroot (Jean Boussier)
Issue #19107 has been updated by byroot (Jean Boussier).
I'm no expert on that area, but my understanding is that lambda specifically handle argument like methods do, not like proc do.
----------------------------------------
Feature #19107: Allow trailing comma in method signature
https://bugs.ruby-lang.org/issues/19107#change-116406
* Author: byroot (Jean Boussier)
* Status: Open
* Assignee: prism
----------------------------------------
A popular style for multiline arrays, hashes or method calls, is to use trailing commas:
```ruby
array = [
1,
2,
3,
]
hash = {
foo: 1,
bar: 2,
baz: 3,
}
Some.method(
1,
2,
foo: 3,
)
```
The main reason to do this is to avoid unnecessary noise when adding one extra element:
```diff
diff --git a/foo.rb b/foo.rb
index b2689a7e4f..ddb7dc3552 100644
--- a/foo.rb
+++ b/foo.rb
@@ -1,4 +1,5 @@
Foo.bar(
foo: 1,
- bar: 2
+ bar: 2,
+ baz: 3
)
```
However, this pattern doesn't work with method declarations:
```ruby
def foo(bar:,) # syntax error, unexpected ')'
```
### Proposal
For consistency and convenience I propose to allow trailing commas in method declarations.
--
https://bugs.ruby-lang.org/
______________________________________________
ruby-core mailing list -- ruby-core@ml.ruby-lang.org
To unsubscribe send an email to ruby-core-leave@ml.ruby-lang.org
ruby-core info -- https://ml.ruby-lang.org/mailman3/lists/ruby-core.ml.ruby-lang.org/
^ permalink raw reply related [flat|nested] 18+ messages in thread
* [ruby-core:124795] [Ruby Feature#19107] Allow trailing comma in method signature
2022-11-07 1:19 [ruby-core:110628] [Ruby master Feature#19107] Allow trailing comma in method signature byroot (Jean Boussier)
` (12 preceding siblings ...)
2026-02-12 11:04 ` [ruby-core:124794] " byroot (Jean Boussier) via ruby-core
@ 2026-02-12 11:40 ` Earlopain (Earlopain _) via ruby-core
2026-02-12 12:07 ` [ruby-core:124798] " Earlopain (Earlopain _) via ruby-core
` (2 subsequent siblings)
16 siblings, 0 replies; 18+ messages in thread
From: Earlopain (Earlopain _) via ruby-core @ 2026-02-12 11:40 UTC (permalink / raw)
To: ruby-core; +Cc: Earlopain (Earlopain _)
Issue #19107 has been updated by Earlopain (Earlopain _).
`->(...) {}` is syntax invalid, same as `foo do |...|; end`, in that regard they are more like blocks. Lambdas do check arity though, which is probably what you were talking about. I'll make a separate issue for this to understand what the desired behavior should be if that's ok.
----------------------------------------
Feature #19107: Allow trailing comma in method signature
https://bugs.ruby-lang.org/issues/19107#change-116407
* Author: byroot (Jean Boussier)
* Status: Open
* Assignee: prism
----------------------------------------
A popular style for multiline arrays, hashes or method calls, is to use trailing commas:
```ruby
array = [
1,
2,
3,
]
hash = {
foo: 1,
bar: 2,
baz: 3,
}
Some.method(
1,
2,
foo: 3,
)
```
The main reason to do this is to avoid unnecessary noise when adding one extra element:
```diff
diff --git a/foo.rb b/foo.rb
index b2689a7e4f..ddb7dc3552 100644
--- a/foo.rb
+++ b/foo.rb
@@ -1,4 +1,5 @@
Foo.bar(
foo: 1,
- bar: 2
+ bar: 2,
+ baz: 3
)
```
However, this pattern doesn't work with method declarations:
```ruby
def foo(bar:,) # syntax error, unexpected ')'
```
### Proposal
For consistency and convenience I propose to allow trailing commas in method declarations.
--
https://bugs.ruby-lang.org/
______________________________________________
ruby-core mailing list -- ruby-core@ml.ruby-lang.org
To unsubscribe send an email to ruby-core-leave@ml.ruby-lang.org
ruby-core info -- https://ml.ruby-lang.org/mailman3/lists/ruby-core.ml.ruby-lang.org/
^ permalink raw reply related [flat|nested] 18+ messages in thread
* [ruby-core:124798] [Ruby Feature#19107] Allow trailing comma in method signature
2022-11-07 1:19 [ruby-core:110628] [Ruby master Feature#19107] Allow trailing comma in method signature byroot (Jean Boussier)
` (13 preceding siblings ...)
2026-02-12 11:40 ` [ruby-core:124795] " Earlopain (Earlopain _) via ruby-core
@ 2026-02-12 12:07 ` Earlopain (Earlopain _) via ruby-core
2026-02-23 4:43 ` [ruby-core:124867] " nobu (Nobuyoshi Nakada) via ruby-core
2026-02-23 11:34 ` [ruby-core:124868] " Earlopain (Earlopain _) via ruby-core
16 siblings, 0 replies; 18+ messages in thread
From: Earlopain (Earlopain _) via ruby-core @ 2026-02-12 12:07 UTC (permalink / raw)
To: ruby-core; +Cc: Earlopain (Earlopain _)
Issue #19107 has been updated by Earlopain (Earlopain _).
https://github.com/ruby/prism/pull/3920 for the prism implementation. I plan to add https://bugs.ruby-lang.org/issues/21875 to the next devmeeting.
----------------------------------------
Feature #19107: Allow trailing comma in method signature
https://bugs.ruby-lang.org/issues/19107#change-116411
* Author: byroot (Jean Boussier)
* Status: Open
* Assignee: prism
----------------------------------------
A popular style for multiline arrays, hashes or method calls, is to use trailing commas:
```ruby
array = [
1,
2,
3,
]
hash = {
foo: 1,
bar: 2,
baz: 3,
}
Some.method(
1,
2,
foo: 3,
)
```
The main reason to do this is to avoid unnecessary noise when adding one extra element:
```diff
diff --git a/foo.rb b/foo.rb
index b2689a7e4f..ddb7dc3552 100644
--- a/foo.rb
+++ b/foo.rb
@@ -1,4 +1,5 @@
Foo.bar(
foo: 1,
- bar: 2
+ bar: 2,
+ baz: 3
)
```
However, this pattern doesn't work with method declarations:
```ruby
def foo(bar:,) # syntax error, unexpected ')'
```
### Proposal
For consistency and convenience I propose to allow trailing commas in method declarations.
--
https://bugs.ruby-lang.org/
______________________________________________
ruby-core mailing list -- ruby-core@ml.ruby-lang.org
To unsubscribe send an email to ruby-core-leave@ml.ruby-lang.org
ruby-core info -- https://ml.ruby-lang.org/mailman3/lists/ruby-core.ml.ruby-lang.org/
^ permalink raw reply related [flat|nested] 18+ messages in thread
* [ruby-core:124867] [Ruby Feature#19107] Allow trailing comma in method signature
2022-11-07 1:19 [ruby-core:110628] [Ruby master Feature#19107] Allow trailing comma in method signature byroot (Jean Boussier)
` (14 preceding siblings ...)
2026-02-12 12:07 ` [ruby-core:124798] " Earlopain (Earlopain _) via ruby-core
@ 2026-02-23 4:43 ` nobu (Nobuyoshi Nakada) via ruby-core
2026-02-23 11:34 ` [ruby-core:124868] " Earlopain (Earlopain _) via ruby-core
16 siblings, 0 replies; 18+ messages in thread
From: nobu (Nobuyoshi Nakada) via ruby-core @ 2026-02-23 4:43 UTC (permalink / raw)
To: ruby-core; +Cc: nobu (Nobuyoshi Nakada)
Issue #19107 has been updated by nobu (Nobuyoshi Nakada).
Assignee changed from prism to core
What about the lambda arguments?
commit:731b6092e9268af960bf0f060e37504f4deb7380 seems not to allow `->(a,) {}`.
----------------------------------------
Feature #19107: Allow trailing comma in method signature
https://bugs.ruby-lang.org/issues/19107#change-116523
* Author: byroot (Jean Boussier)
* Status: Closed
* Assignee: core
----------------------------------------
A popular style for multiline arrays, hashes or method calls, is to use trailing commas:
```ruby
array = [
1,
2,
3,
]
hash = {
foo: 1,
bar: 2,
baz: 3,
}
Some.method(
1,
2,
foo: 3,
)
```
The main reason to do this is to avoid unnecessary noise when adding one extra element:
```diff
diff --git a/foo.rb b/foo.rb
index b2689a7e4f..ddb7dc3552 100644
--- a/foo.rb
+++ b/foo.rb
@@ -1,4 +1,5 @@
Foo.bar(
foo: 1,
- bar: 2
+ bar: 2,
+ baz: 3
)
```
However, this pattern doesn't work with method declarations:
```ruby
def foo(bar:,) # syntax error, unexpected ')'
```
### Proposal
For consistency and convenience I propose to allow trailing commas in method declarations.
--
https://bugs.ruby-lang.org/
______________________________________________
ruby-core mailing list -- ruby-core@ml.ruby-lang.org
To unsubscribe send an email to ruby-core-leave@ml.ruby-lang.org
ruby-core info -- https://ml.ruby-lang.org/mailman3/lists/ruby-core.ml.ruby-lang.org/
^ permalink raw reply related [flat|nested] 18+ messages in thread
* [ruby-core:124868] [Ruby Feature#19107] Allow trailing comma in method signature
2022-11-07 1:19 [ruby-core:110628] [Ruby master Feature#19107] Allow trailing comma in method signature byroot (Jean Boussier)
` (15 preceding siblings ...)
2026-02-23 4:43 ` [ruby-core:124867] " nobu (Nobuyoshi Nakada) via ruby-core
@ 2026-02-23 11:34 ` Earlopain (Earlopain _) via ruby-core
16 siblings, 0 replies; 18+ messages in thread
From: Earlopain (Earlopain _) via ruby-core @ 2026-02-23 11:34 UTC (permalink / raw)
To: ruby-core; +Cc: Earlopain (Earlopain _)
Issue #19107 has been updated by Earlopain (Earlopain _).
> What about the lambda arguments?
@nobu it's unclear to me so I didn't change them. I added https://bugs.ruby-lang.org/issues/21875 to the next dev meeting.
----------------------------------------
Feature #19107: Allow trailing comma in method signature
https://bugs.ruby-lang.org/issues/19107#change-116524
* Author: byroot (Jean Boussier)
* Status: Closed
* Assignee: core
----------------------------------------
A popular style for multiline arrays, hashes or method calls, is to use trailing commas:
```ruby
array = [
1,
2,
3,
]
hash = {
foo: 1,
bar: 2,
baz: 3,
}
Some.method(
1,
2,
foo: 3,
)
```
The main reason to do this is to avoid unnecessary noise when adding one extra element:
```diff
diff --git a/foo.rb b/foo.rb
index b2689a7e4f..ddb7dc3552 100644
--- a/foo.rb
+++ b/foo.rb
@@ -1,4 +1,5 @@
Foo.bar(
foo: 1,
- bar: 2
+ bar: 2,
+ baz: 3
)
```
However, this pattern doesn't work with method declarations:
```ruby
def foo(bar:,) # syntax error, unexpected ')'
```
### Proposal
For consistency and convenience I propose to allow trailing commas in method declarations.
--
https://bugs.ruby-lang.org/
______________________________________________
ruby-core mailing list -- ruby-core@ml.ruby-lang.org
To unsubscribe send an email to ruby-core-leave@ml.ruby-lang.org
ruby-core info -- https://ml.ruby-lang.org/mailman3/lists/ruby-core.ml.ruby-lang.org/
^ permalink raw reply related [flat|nested] 18+ messages in thread
end of thread, other threads:[~2026-02-23 11:34 UTC | newest]
Thread overview: 18+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-11-07 1:19 [ruby-core:110628] [Ruby master Feature#19107] Allow trailing comma in method signature byroot (Jean Boussier)
2022-12-01 7:46 ` [ruby-core:111113] " matz (Yukihiro Matsumoto)
2022-12-01 8:51 ` [ruby-core:111122] " byroot (Jean Boussier)
2023-02-13 6:20 ` [ruby-core:112393] " rubyFeedback (robert heiler) via ruby-core
2023-02-13 6:43 ` [ruby-core:112394] " k0kubun (Takashi Kokubun) via ruby-core
2026-01-14 1:09 ` [ruby-core:124520] [Ruby " k0kubun (Takashi Kokubun) via ruby-core
2026-02-12 4:12 ` [ruby-core:124775] " matz (Yukihiro Matsumoto) via ruby-core
2026-02-12 7:53 ` [ruby-core:124781] " Earlopain (Earlopain _) via ruby-core
2026-02-12 7:59 ` [ruby-core:124782] " byroot (Jean Boussier) via ruby-core
2026-02-12 7:59 ` [ruby-core:124783] " byroot (Jean Boussier) via ruby-core
2026-02-12 8:51 ` [ruby-core:124789] " Earlopain (Earlopain _) via ruby-core
2026-02-12 8:54 ` [ruby-core:124790] " byroot (Jean Boussier) via ruby-core
2026-02-12 10:52 ` [ruby-core:124793] " Earlopain (Earlopain _) via ruby-core
2026-02-12 11:04 ` [ruby-core:124794] " byroot (Jean Boussier) via ruby-core
2026-02-12 11:40 ` [ruby-core:124795] " Earlopain (Earlopain _) via ruby-core
2026-02-12 12:07 ` [ruby-core:124798] " Earlopain (Earlopain _) via ruby-core
2026-02-23 4:43 ` [ruby-core:124867] " nobu (Nobuyoshi Nakada) via ruby-core
2026-02-23 11:34 ` [ruby-core:124868] " Earlopain (Earlopain _) via ruby-core
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).