From: Daniel Finnie Date: 2007-01-13T05:17:47+09:00 Subject: Re: Why doesn't Ruby allow for overloaded methods within a c It goes 100% against duck typing. class Name < String # ... end def methodName(String a) # ... end Does methodName accept the Name class? And what if you just had a NumericString class that implemented all of the String and Numeric methods, but wasn't a descendant of either class? Would methodName(String a) accept that class as input? Dan Max Lapshin wrote: > Wes Gamble wrote: >> Thanks, I hadn't considered that. >> >> Wes > > Think about this: > > class Foo > def methodname(Foo a) > puts a.value > end > > def methodname(String a) > puts "bar: "+a > end > end > > > class FooTest < Test::Unit::TestCase > def test_methodname > @mock_foo = "some mock string value" > def @mock_foo.value > self > end > @foo = Foo.new > assert_equal "some mock string value", @foo.methodname(@mock_foo) > end > end > > > Problems =) > >