How do splat (*) and double splat (**) operators work in method arguments?

Last updated 27 June 2026

  • In a definition, *args gathers positional arguments into an Array and **opts gathers keyword arguments into a Hash.

  • At a call site they work in reverse: *array expands into positional args and **hash into keyword args.

  • Forward everything with *args, **kwargs, &block or ... (Ruby 2.7+).

  • https://docs.ruby-lang.org/en/3.0/syntax/methods_rdoc.html
  • https://docs.ruby-lang.org/capi/en/master/d8/d6b/diagnostic_8c_source.html
  • https://docs.ruby-lang.org/en/3.1/syntax/calling_methods_rdoc.html
  • https://docs.ruby-lang.org/en/master/syntax/calling_methods_rdoc.html
  • https://www.ruby-lang.org/en/news/2019/12/12/separation-of-positional-and-keyword-arguments-in-ruby-3-0/
  • https://www.railscarma.com/blog/guide-to-the-ruby-splat-operator-single-and-double/
  • https://medium.com/@kabirpathak99/ruby-splat-and-double-splat-operators-18ebb733eb4c
  • https://dev.to/jasonfb/ruby-arguments-40m4
All Ruby interview questions