On Tue, Mar 5, 2013 at 8:07 PM, Hans Mackowiak <[email protected]> wrote:
> they values you used for next are returned by yield ...
> (so all block functions that does something different depending on the
> block result does be affected like: .map, .select, .find, .group_by and
> others )

Like with:

irb(main):025:0> 10.times.map {|i| next if i == 2;i*10}
=> [0, 10, nil, 30, 40, 50, 60, 70, 80, 90]

"next" is for a block about the same as a "return" for a method: the
current call is terminated at this point with the provided arguments
given to the caller (the "yield").  And since "next" is a keyword it
does make sense to have it follow the same syntax rules for arguments
like "return" and "break".

Hans, thank you for the heads up!

Kind regards

robert


-- 
remember.guy do |as, often| as.you_can - without end
http://blog.rubybestpractices.com/

-- 
[email protected] | 
https://groups.google.com/d/forum/ruby-talk-google?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
"ruby-talk-google" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to