On Sep 7, 2010, at 21:53 , Robert Rice wrote:

> I didn't see super in the ruby-doc.org/ruby-1.9/index.html unless super is 
> short for superclass.

In Ruby, super is not a real method call but a key word. Also, it does not 
behave exactly like a method call (implicit arguments/block and what not). 
Therefore it is not in the generated method list.

> 
> Can I reach a superclass method without having the message go first to my 
> subclass override of the method?

Not as easily and general as in Smalltalk but you can do something like this:


        class Foo
                def foo
                        20
                end
        end

        class Bar < Foo
                def foo
                        super * 2
                end
        end

        class Baz < Bar
                def foo
                        method = Foo.instance_method(__method__).bind(self)
                        method.call
                end
        end

        puts Foo.new.foo # => 20
        puts Bar.new.foo # => 40
        puts Baz.new.foo # => 20

Konstantin

_______________________________________________
MacRuby-devel mailing list
MacRuby-devel@lists.macosforge.org
http://lists.macosforge.org/mailman/listinfo.cgi/macruby-devel

Reply via email to