> class Person
>
> =A0def print_details(name)
> =A0 =A0"Hey My Name is #{name}"
> =A0end
>
> =A0def print_details(name,age)
> =A0 =A0"Hey My Name is #{name} and #{age}"
> =A0end
> end

You can use default arguments in this case.

def print_details(name, age =3D nil)
  s =3D "Hey My Name is #{name}"
  s << " and age #{age}" if age
  puts s
end

A piece of advice - A function's name and action should match. In this
case, you name the method print_detail but do not print it. Seems like
you expect to use the return value elsewhere; call the method just
'details' in that case.

> person1 =3D Person.new
> puts person1.print_details("peter")
> puts person1.print_details("pk",25)
>
> =A0I got The error =A0wrong number of arguments (1 for 2) (ArgumentError)=
.

Yeah. The second definition now binds to 'print_details'.

> =A0Why Ruby does not support the method overloading ???

Thats the Ruby way. Ruby makes up for function overloading with its
flexible argument processing ability, like Victor pointed out.

--=20
Anurag Priyam
http://about.me/yeban/