2011/4/17 Fily Salas <fs_tigre / hotmail.com>:
> def multiply(val1, val2 )
>   result = val1 * val2
>   return result
> end

A ruby method always returns the last object or expression it calls
internally. But if there is a return(something) within the method then
such object "something" is returned by the method. Note also that
"return" is the same as "return nil".

In your above method, it would be the same as:

def multiply(val1, val2 )
    result = val1 * val2
end


or also:


def multiply(val1, val2 )
    result = val1 * val2
    result
end


The advantage of using "return" is that you terminate the method when
you want without running the remaining code defined in the method.


-- 
Iaki Baz Castillo
<ibc / aliax.net>