Project

General

Profile

Misc #10469

Documented return value for Array#each

Added by jaredbeck (Jared Beck) almost 3 years ago. Updated over 2 years ago.

Status:
Closed
Priority:
Normal
[ruby-core:66063]

Description

This is a minor documentation suggestion.

When given a block, Array#each returns self.

[1,2,3].each { |x| 'banana' }
#=> [1, 2, 3]

However, this is not obvious (to me) from the documentation.

The documented method signature is each { |item| block } → ary. Perhaps most people would understand that ary is self, but I think it could be more clear.

Perhaps something like the following (change in bold):

Calls the given block once for each element in self, passing that element as a parameter, and returning the array itself.

Thanks!

array_each_return_docs.patch (927 Bytes) array_each_return_docs.patch jaredbeck (Jared Beck), 11/03/2014 06:57 AM

Associated revisions

Revision 49217
Added by hsbt (Hiroshi SHIBATA) over 2 years ago

  • array.c (rb_ary_each): documented return value. [misc #10469]

Revision 49217
Added by hsbt (Hiroshi SHIBATA) over 2 years ago

  • array.c (rb_ary_each): documented return value. [misc #10469]

Revision 49217
Added by hsbt (Hiroshi SHIBATA) over 2 years ago

  • array.c (rb_ary_each): documented return value. [misc #10469]

History

#2 [ruby-core:67542] Updated by hsbt (Hiroshi SHIBATA) over 2 years ago

  • Status changed from Open to Closed

Also available in: Atom PDF