You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
We have to use `ruby2_keywords` because that's [the only way](https://eregon.me/blog/2021/02/13/correct-delegation-in-ruby-2-27-3.html) to achieve correct delegation on Ruby 2.7.
22
+
We otherwise avoid it (it's not defined on Ruby < 2.7 or it's noop) because it seems a bad idea to use a method named `ruby2*` on Ruby 3+.
23
+
24
+
An alternative is to use `(...)` on >= 2.7 and `(*args)` on < 2.7, but this requires `class_eval` because `(...)` is invalid syntax for < 2.7:
25
+
```ruby
26
+
args =RUBY_VERSION>='2.7'?'...' : '*args, &block'
27
+
class_eval <<~RUBY
28
+
deffoo(#{args})
29
+
bar(#{args})
30
+
end
31
+
RUBY
32
+
```
33
+
34
+
To test that the delegation is correct, see commit `89d9fef36a6b894b039bc1d9ef6ed0af2c7a92bb`.
35
+
36
+
More details on this in [this blog post from Benoit](https://eregon.me/blog/2021/02/13/correct-delegation-in-ruby-2-27-3.html) and [this ruby-lang.org article](https://www.ruby-lang.org/en/news/2019/12/12/separation-of-positional-and-keyword-arguments-in-ruby-3-0/).
0 commit comments