Naked asterisk as method only parameter in Ruby

July, 2020

Useful when you need to accept any number of parameters, but you actually don't care about them or you just want to pass them away to the superclass method.

class Bar
  def do_something(*args)
    puts "Passed args: #{args.inspect}"
  end
end

class Foo < Bar
  def do_something(*)
    super
  end
end

Foo.new.do_something("hello", "world")
#=> Passed args: ["hello", "world"]