I have some experience with programming in other languages, but I'm new
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"):
#inits some instance variables
class B < A
def initialize(x, y)
myX = x
myY = y
If I create instances of B in the same file (!), everything is OK
b = B.new('sth', 'anotherSth')
But if create another file and 'include modA' and do the same all I get
../blogdata.rb:23:in `initialize': wrong number of arguments(0 for 2)
from ./blogdata.rb:23:in `new'
from ./blogdata.rb:23:in `initialize'
from ./blogdata.rb:32:in `initialize'
from UI.rbw:5:in `new'
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."
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,