From: Michael Weller Date: 2004-01-23T22:19:58+09:00 Subject: [BEGINNER] Usage of 'super' Hi! I have some experience with programming in other languages, but I'm new to Ruby. Here's a problem I encoutered writing my first program: I got these two classes, both classes are defined in the same file (let's call it "modA"): class A def initialize #inits some instance variables end end class B < A def initialize(x, y) super @myX = x @myY = y end end If I create instances of B in the same file (!), everything is OK (e.g.: b = B.new('sth', 'anotherSth') puts b.toS ). But if create another file and 'include modA' and do the same all I get is this: ../blogdata.rb:23:in `initialize': wrong number of arguments(0 for 2) (ArgumentError) from ./blogdata.rb:23:in `new' from ./blogdata.rb:23:in `initialize' from ./blogdata.rb:32:in `initialize' from UI.rbw:5:in `new' from UI.rbw:5 So it seems like B is trying to pass the two params it received on to A. A doesn't define 'initialize' with two params to I get an error. I looked in the "Ruby Man Docs" and on the syntax page the author states: "the super invokes the method which the current method overrides. If no arguments given, arguments to the current method passed to the method." My questions: Can I change this behaviour? Do I need to introduce an "initialize(a,b)' in my A class? Why does it work if my code is written in the same file? Lots of questions I'm sure somebody here can answer! Thanks in advance, Michael