Hi --

On Mon, 19 Feb 2007, 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?

Yes.  You could even do:

   def square(n)
     n * n
   end

and square(3) will evaluate to 9 (the value of the last expression in
the method before it ends).  (Aside to Xavier: I know, it's just an
illustration :-)


David

-- 
Q. What is THE Ruby book for Rails developers?
A. RUBY FOR RAILS by David A. Black (http://www.manning.com/black)
    (See what readers are saying!  http://www.rubypal.com/r4rrevs.pdf)
Q. Where can I get Ruby/Rails on-site training, consulting, coaching?
A. Ruby Power and Light, LLC (http://www.rubypal.com)