Ruby Keyword: super - rking/pry-docmore GitHub Wiki

Call the current method, but using the superclass's implementation. Can be useful so that subclasses can 'decorate' their parent class's functionality.

A subtle syntax issue is that, when this is called with no arguments, all arguments are passed up.

For example:

class Dad
  def f *args; p args end
end
class Kid < Dad
  def f *args; super end
end
Kid.new.f 1, 2

Outputs:

[1, 2]

The way to stop this behavior is to use something Ruby almost never requires: empty parens:

class Dad
  def f *args; p args end
end
class Kid < Dad
  def f *args; super() end
end
Kid.new.f 1, 2

Outputs:

[]
⚠️ **GitHub.com Fallback** ⚠️