19bernardo87
Member
Let's say I have
class Joe
...
def barf
end
...
end
class Boo < Joe
...
def barf
print 'barf!'
end
...
end
module Foo
...
def barf
print 'darf!'
end
...
end
-----------------------------------
Two scenarios
1)
class Boo
...
def barf
print 'darf!'
super
end
...
end
Boo.barf
2)
class Boo
include Foo
end
Boo.barf
It seems that the output of (1) is just 'darf', while (2) gives me 'barf' and 'darf'. That is, the super in (1) class Joe's barf method, while (2) calls Boo's.
Why is that?
class Joe
...
def barf
end
...
end
class Boo < Joe
...
def barf
print 'barf!'
end
...
end
module Foo
...
def barf
print 'darf!'
end
...
end
-----------------------------------
Two scenarios
1)
class Boo
...
def barf
print 'darf!'
super
end
...
end
Boo.barf
2)
class Boo
include Foo
end
Boo.barf
It seems that the output of (1) is just 'darf', while (2) gives me 'barf' and 'darf'. That is, the super in (1) class Joe's barf method, while (2) calls Boo's.
Why is that?