From: Marc-Andre Lafortune <redmine@...>
Date: 2009-10-03T13:51:01+09:00
Subject: [ruby-core:25912] [Bug #2172] Enumerable#chunk with no block

Bug #2172: Enumerable#chunk with no block
http://redmine.ruby-lang.org/issues/show/2172

Author: Marc-Andre Lafortune
Status: Open, Priority: Low
Assigned to: Yukihiro Matsumoto, Category: core
ruby -v: ruby 1.9.2dev (2009-10-03 trunk 25203) [x86_64-darwin10.0.0]

What should "(1..3).chunk" (i.e. without a block) do?

It issued an
ArgumentError: tried to create Proc object without a block

I changed the error message to "no block given" which I hope to be more informative, but maybe there is something more useful to do here?

A default block of {|x| x} doesn't seem all that useful.

Returning an enumerator that, upon completion, will return an enumerator would probably be better, but could also be a bit confusing if someone doesn't realize he forgot to specify the block?

Thanks to Run Paint for raising the question when writing the rubyspec for #chunk.


----------------------------------------
http://redmine.ruby-lang.org