Ruby 3.0.0, released on December 25, 2020, separates keyword arguments from positional arguments. That creates migration work for application and library maintainers whose methods receive a call and pass its arguments to another method. The repair depends on the oldest Ruby version they still support: explicit keyword forwarding suits Ruby 3, while code shared with Ruby 2.6 needs a compatibility approach. [S1][S2]

The change removes an automatic conversion that could hide what a call meant. Ruby's migration guide illustrates a method accepting only a keyword named k. Passing an ordinary Hash containing k as a positional argument worked through conversion in Ruby 2.7 but raises ArgumentError in Ruby 3. Prefixing that Hash with the double-splat operator, **, explicitly passes its contents as keywords. A Hash object and a set of keyword arguments can contain the same information without being interchangeable at the call boundary. [S2]

Forwarding methods need to preserve that distinction. The Ruby 3 form shown in the guide collects positional arguments with *args, keywords with **kwargs and a block with &block, then passes all three to the target method. For a wrapper that does not alter any arguments and does not need Ruby 2.6 compatibility, the guide also offers the ... forwarding syntax introduced in Ruby 2.7. [S2]

For a library spanning Ruby 2.6, 2.7 and 3.0, the guide recommends keeping the older *args and &block forwarding pattern and marking the forwarding method with ruby2_keywords. That marker lets the final Hash retain its keyword role when it is passed onward. Ruby 2.6 does not define ruby2_keywords, so the guide calls for the compatibility gem or a compatibility definition on that version. Adding **kwargs everywhere would miss why this bridge exists: older Ruby versions do not handle the new forwarding pattern the same way. [S2]

Empty arguments make useful migration tests. In the guide's Ruby 2.7 example, a wrapper accepting *args and **kwargs absorbs an empty positional Hash into its keywords and then forwards no argument to the target. In its Ruby 2.6 example, a call with no arguments goes the other way: explicit keyword forwarding delivers an empty Hash as a positional argument. For an upgrade, test no arguments, an empty positional Hash and actual keywords separately on each supported runtime before changing a shared wrapper. The guide describes those edge cases; it does not establish that an application has passed them. [S2]

Not every options-Hash method needs to become a keyword method. The guide explicitly preserves its example of a method with one optional positional Hash parameter and no keyword parameters: a keyword-looking call still supplies that Hash in Ruby 3. That leaves two different contracts to preserve during an upgrade: an intentional options object and keywords expected by the target. [S2]

Source documents

  1. Ruby 3.0.0 Releasedhttps://www.ruby-lang.org/en/news/2020/12/25/ruby-3-0-0-released/
  2. Separation of positional and keyword arguments in Ruby 3.0https://www.ruby-lang.org/en/news/2019/12/12/separation-of-positional-and-keyword-arguments-in-ruby-3-0/