Ruby on Rails Saturday, October 29, 2011

On Sat, Oct 29, 2011 at 00:09, John Merlino <stoicism1@aol.com> wrote:

> ruby-1.9.2-p136 :095 > portfolio.each {|n, b| n <=> b }
> NoMethodError: undefined method `balance' for nil:NilClass
>
> It appears that the each iterator does not support passing in two
> arguments?

Correct. "each" means "apply this block to each of this collection's
elements in turn", not "... in parallel". Otherwise you'd have to
have the block accept exactly as many args as there are elements. (Or
of course accept a collection, in which case you're back to square
one.)

-Dave

--
LOOKING FOR WORK! What: Ruby (on/off Rails), Python, other modern languages.
Where: Northern Virginia, Washington DC (near Orange Line), and remote work.
See: davearonson.com (main) * codosaur.us (code) * dare2xl.com (excellence).
Specialization is for insects. (Heinlein) - Have Pun, Will Babble! (Aronson)

--
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 rubyonrails-talk@googlegroups.com.
To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.

No comments:

Post a Comment