Project

General

Profile

Actions

Feature #2172

closed

Enumerable#chunk with no block

Added by marcandre (Marc-Andre Lafortune) about 15 years ago. Updated about 8 years ago.

Status:
Closed
Target version:
-
[ruby-core:25912]

Description

=begin
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.
=end

Actions

Also available in: Atom PDF

Like0
Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0