From: matz@... (Yukihiro Matsumoto) Date: 2001-06-28T11:13:45+09:00 Subject: [ruby-talk:16981] Re: Method overloading (option) Was: Re: Hi, In message "[ruby-talk:16972] Re: Method overloading (option) Was: Re:" on 01/06/28, Hugh Sasse Staff Elec Eng writes: |> If you give an object of wrong protocol, you'll get NameError (well, | |I'm not sure what you mean here. (That could be because I'm implementing |a 'protocol' on top of UDP at the moment, so I'm see the word differently |from you! :-)) Can you give an example of how a NameError can come from |passing the wrong object to a user defined method, without using type |dispatch, please? This may help me see your Ruby Way. def split(obj) a = [] len = obj.size for i in 0...len a.push obj[i] end a end p split("abc") # [?a, ?b, ?c] p split([1,2,3]) # [1, 2, 3] p split(:foo) # -:3:in `split': undefined method `size' for :foo:Symbol (NameError) the "split" takes any object that responds to "size" and "[]". "size" and "[]" are protocol this case. matz.