On 21 Jun 2007, at 14:55, danielj wrote:

> just to be perfectly clear, i mean that i don't understand why it is 6
> and 36
>
> so basically, i don't understand what the method does on the "inside"

It would be easier to explain if you said what you *are* expecting to  
happen!

> def mtdarry
>
>   10.times do |num|
>
>     square = num * num
>
>     return num, square if num > 5
>
>   end
>
> end

The 10.times block (do/end) is called with the integer 'num'. The  
first time it is called with 0 and each subsequent time this number  
is increased by 1. Each time through the loop you calculate the  
square of the number. You return from the method when the number is  
greater than 5 (i.e. when it is 6). Your method therefore returns 6  
and 36 (the square of 6).

Hope that helps.

Alex Gutteridge

Bioinformatics Center
Kyoto University