simple_enum icon indicating copy to clipboard operation
simple_enum copied to clipboard

Use double-splat for Ruby 3.0 compatibility

Open qnighy opened this issue 3 years ago • 4 comments

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_enum compatible 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.

qnighy avatar Jan 06 '21 08:01 qnighy

Hi @qnighy thank you for your PR. Just a question: to avoid code duplication why you didn't use RUBY_VERSION, something like

if RUBY_VERSION < "1.9"
   I18n.translate(defaults.shift, options)
else   
    I18n.translate(defaults.shift, **options)
end

guillaumebesse avatar Jan 14 '22 08:01 guillaumebesse

Because in the old Ruby, SyntaxError would be raised before executing the whole if expression.

qnighy avatar Jan 14 '22 08:01 qnighy

any updates on this PR? I really need these changes.

softbrada avatar Aug 04 '22 08:08 softbrada

@guillaumebesse any chance you could fix up the PR and merge it?

lwe avatar Aug 15 '22 13:08 lwe