> I think Function Overloading in C++ is very meaningful. And <BR>> currently <BR>> the case for me is: How I can make use of method/function <BR>> overloading <BR>> in Ruby?<BR>>esides you might tell me Ruby is designed to exclude method <BR>>verloading, can you tell me sth more for the Overloading purpose?<BR><BR> There are quite a few thread on overloading around here,ut I'll make a short summary (once for all, hopefully ?). C++ overloading has basically two purposes:<BR><BR> 1) get aroundtrict typing limitations (a function working on numbers might want to work on int, float, double...)<BR> 2) provide defalt values (though it is not really overloading, it really looks like it).<BR><BR> In my opinion, any other way to use overloading (that is, a function doing something completely different when called with (int, double) than with (double) is characteristic of bad programming practices).<BR><BR> Ruby provides solutions for both cases:<BR><BR> 1) you don't need to declare type for a ruby function,o you can call one unique function with many different types. If youeed to separate some cases depending on the type of one of the argument, try something like:<BR><BR> case argument<BR> when String<BR> do something with the string<BR> when Array<BR>...<BR> end<BR><BR> The best approach to this isrobably 'duck typing', that is: you don't care what objects the function is fed to, as long as the behave correctly (they have theight methods that do something appropriate)<BR><BR> 2) ruby provides default arguments as well (more powerful than C++):<BR><BR>irb(main):004:0> def m(a, b = 0, c = a) <BR>irb(main):005:1> [a,b,c]<BR>irb(main):006:1> end<BR>=> nil<BR>irb(main):007:0> m(1)<BR>=> [1,, 1]<BR>irb(main):008:0> <BR><BR> Does that answer your question, or you know some other uses of overloading I didn't mention ?<BR><BR> Cheers,<BR><BR> Vince