Ruby is cheating on super
The super call in Ruby differs in semantics from many other oo-languages. You are not simply refering to the class definition one level above, but just the method definition one level above. Additionally you may use super without arguments to tell the interpreter to use the same ones, the current method just received.
But this leaves one question open. How could you call super with no argument, while the current method received some. Besides super being a reserved word it should act as natural as possible and ideally feel like any message send. But it doesn’t, unfortunately.
Please look at the following sample code.
def method_with_default_parameter(arg0 = :default)
class InheritingClass < BaseClass
And guess what happens when this is called
# => [:custom, :default, :custom]
In some way this desired behaviour, but not what I would call least suprise.
Ruby differentiates in this case between
super(). This is only
possible since the parser already knows
super and nobody can emulate that with
a custom message sends. A nasty trick that does not allow any api using
to provide a similar behaviour in similar situations.
Could be corrected in 1.9. What do you think?
I mainly work with Rails, Backbone, and Bootstrap, but I am also good at picking up new frameworks, since I will probably know most of their concepts from other projects.