Gavin Kistner
2/10/2005 2:37:00 PM
On Jan 27, 2005, at 11:18 AM, Mystifier wrote:
> The current situation in Ruby with method calls is
>
> class A
> def meth(arg1)
> end
> end
>
> class B < A
> def meth(arg1,arg2)
> end
> end
>
> a = A.new
> b = B.new
>
> b.meth(1,2) is fine but a.meth(1,2) . This is fine but what one
> assumes is
> that when a method is overridden, you wish to override the
> implementation.
> In that case, this is a problem.
If you wish to override the implementation, then you should do so:
class A
def meth(arg1)
end
end
#...later...
class A
def meth(arg1,arg2)
end
end
It would not make sense to affect/change a parent class that you
inherit from. Consider:
class Animal
def eat
gobble_ravenously()
end
end
class Person < Animal
def eat
use_fork_and_knife()
end
end
If the 'redefinition' of #eat by the Person class affected the Animal
class, all animals would suddenly be using cutlery.
Am I misunderstanding you?