On 25.02.2012, at 23:41, John Merlino wrote:

> I was always under assumption that the block accepts the return value
> of the iterator as the argument to the block, but look at this:
> 
> Array.new(500) do | i |
>      puts i
> end
> 
> 
> I expect i to be an array instance with 500 indexes all will nil
> values. However, what it returns is indeed an array with 500 indexes
> all with nil values BUT before it returns that array instance, the
> block appears to execute 500 times passing an actual integer value
> into the block incrementing by 1 each time. I dont understand why this
> is happening.

Because 'puts()' always return nil. It just generates STDOUT output.

-- 
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.

Reply via email to