[MacRuby-devel] super method

Caius Durling caius at caius.name
Wed Sep 8 09:31:46 PDT 2010


On 8 Sep 2010, at 17:22, Matt Aimonetti wrote:

> 3) If I have an empty init, e.g.,  def init; super; self; end
>        Can I always delete  the empty init and get the same result through inheritance?


Yes. Ruby will look for the method in your subclass, then go up the class hierarchy to the superclass and check there for the method there, calling it if it's found.

So a method that just contains 'super' [although not 'super()' as that calls super with no arguments] is doing the same job as the method not being defined in the subclass.

C
---
Caius Durling
caius at caius.name
+44 (0) 7960 268 100
http://caius.name/



More information about the MacRuby-devel mailing list