Use double-splat for Ruby 3.0 compatibility#150
Conversation
|
Hi @qnighy thank you for your PR. |
|
Because in the old Ruby, SyntaxError would be raised before executing the whole |
|
any updates on this PR? I really need these changes. |
|
@guillaumebesse any chance you could fix up the PR and merge it? |
| require 'simple_enum/translation' | ||
| begin | ||
| require 'simple_enum/translation' | ||
| rescue SyntaxError |
There was a problem hiding this comment.
i am not a maintainer, or contributor to this project, probably should also be ArgumentError here. On Ruby 2.6 i get ArgumentError rather than SyntaxError. Just sharing my thoughts
|
|
||
| options.reverse_merge! count: 1, default: defaults | ||
| I18n.translate(defaults.shift, options) | ||
| I18n.translate(defaults.shift, **options) |
There was a problem hiding this comment.
i am not a maintainer, or contributor to this project, but seems brittle to me to have this whole file duplicated to fix a single line.
We could rescue here the exception so we avoid duplicating unnecessary code. Just my thoughts
Ruby 3.0 separates keyword arguments from positional arguments. https://www.ruby-lang.org/en/news/2019/12/12/separation-of-positional-and-keyword-arguments-in-ruby-3-0/
This PR makes
simple_enumcompatible with the new behavior. As**isn't supported in Ruby 1.9, this PR falls back to the old source code without**when a syntax error occurs.