"Personal" method in ruby
Posted
by steve gooberman-hill
on Stack Overflow
See other posts from Stack Overflow
or by steve gooberman-hill
Published on 2010-03-31T20:08:57Z
Indexed on
2010/03/31
20:13 UTC
Read the original article
Hit count: 250
ruby
I'm looking for a way of making a method "personal" - note NOT PRIVATE to a class
here is an example - by "personal" I mean the behaviour of method "foo"
class A
def foo
"foo"
end
end
class B < A
def foo
"bar"
end
end
class C < B
end
a=A.new; b=B.new;c=C.new
I'm looking for a way of producing the following behaviour
a.foo #=> "foo"
b.foo #=> "bar"
c.foo #=> "foo" (ultimate base class method called)
Any ideas?
Thanks
Steve
© Stack Overflow or respective owner