On Feb 19, 2007, at 3:44 PM, Derek Teixeira wrote:

>
>>    def square(n)
>>      s = n*n
>>      return s
>>    end
>>
>   so right here we could have gotten rid of the "return" and then  
> below
> just write
>
> puts square(3)
>
> and the code will give us 9?
> because it returns to us that s value, and we are putting that value?

Exactly.

Now that you have grasped the meaning of return, let me say that not  
all languages make it optional at the end, some programming languages  
do require an explicit return.

Additionally, in that example the variable "s" is superfluous, you  
can just write

   return n*n

but I wanted to have a simple method with two lines of code instead  
of one, so that it was visually evident there was a last line of code  
in a series of lines.

-- fxn