From: Juston Davies Date: 2009-07-21T00:50:48+09:00 Subject: Re: Issues with inheritance You nailed it. I tip my hat to you. I also figured out why child2 looked like it invoking itself, that was a perception error on my part. Thanks! On Jul 20, 9:45 am, James Coglan wrote: > > The first problem I see is that when I call super.execute it seems to > > want to ignore my argument and favor of the argument I gave at the > > hight level of scope. (If I do str = "Robin" in Child2's execute but > > still call super.execute("batman") it prints ">Robin" in subsequent > > levels.) The second is that Child2 somehow calls execute on itself > > once before digging into the next level of the tree, then at the last > > level it tries to call it on an empty array which goes against the > > program logic. I'm not new to programming, I've probably built this > > exact same thing in Java, but I am new to Ruby. Whats wrong with what > > I'm trying to do? > > In Ruby, you just call super() to call the parent method. There are three > use cases for super: > > * Implicit args: `super` -- this calls the parent method with the same > arguments as the current method call. > * No args: `super()` -- the explicit empty parens mean call the parent > method with no arguments, whatever the current method was called with. > * Explicit args: `super(arg1, arg2 ...)` -- calls the parent method with the > given arguments. > > Hope that helps. > > -- > James Coglanhttp://jcoglan.com