> class Person
>
>   > Hey My Name is #{name}"
>  
>
>   > Hey My Name is #{name} and #{age}"
>  
> end

You can use default arguments in this case.

def print_details(name, age = nil)
  s = "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 = Person.new
> puts person1.print_details("peter")
> puts person1.print_details("pk",25)
>
>  

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

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

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