Project

General

Profile

Actions

Bug #10944

closed

Documentation of Array.new w.r.t. element index available to a block

Added by dgc (Don Cruickshank) over 9 years ago. Updated over 7 years ago.

Status:
Closed
Assignee:
-
Target version:
-
ruby -v:
ruby 2.0.0p353 (2013-11-22 revision 43784) [i386-linux]
[ruby-core:68442]

Description

In http://ruby-doc.org/core-2.2.1/Array.html#class-Array-label-Creating+Arrays

The documentation for the Array.new method is missing the fact that the element index is available to a given block.

E.g.

Array.new(4) { |x| x } #=> [0, 1, 2, 3]

Updated by cremno (cremno phobia) over 9 years ago

The actual Array.new documentation mentions and also provides an example for this:

http://ruby-doc.org/core-2.2.1/Array.html#method-c-new (second code block)

Updated by stomar (Marcus Stollsteimer) over 7 years ago

Although it's already documented in Array.new, an additional example in the class documentation cannot hurt; so I'll add one.

Actions #3

Updated by stomar (Marcus Stollsteimer) over 7 years ago

  • Status changed from Open to Closed

Applied in changeset r58037.


docs for creating arrays

  • array.c: [DOC] add example for Array.new with block and index.
    Reported by Don Cruickshank. [ruby-core:68442] [Bug #10944]
Actions #4

Updated by usa (Usaku NAKAMURA) over 7 years ago

  • Backport changed from 2.0.0: UNKNOWN, 2.1: UNKNOWN, 2.2: UNKNOWN to 2.2: REQUIRED, 2.3: REQUIRED, 2.4: REQUIRED

Updated by usa (Usaku NAKAMURA) over 7 years ago

  • Backport changed from 2.2: REQUIRED, 2.3: REQUIRED, 2.4: REQUIRED to 2.2: DONE, 2.3: REQUIRED, 2.4: REQUIRED

ruby_2_2 r58129 merged revision(s) 58037.

Updated by nagachika (Tomoyuki Chikanaga) over 7 years ago

  • Backport changed from 2.2: DONE, 2.3: REQUIRED, 2.4: REQUIRED to 2.2: DONE, 2.3: DONE, 2.4: REQUIRED

ruby_2_3 r58163 merged revision(s) 58037.

Updated by nagachika (Tomoyuki Chikanaga) over 7 years ago

  • Backport changed from 2.2: DONE, 2.3: DONE, 2.4: REQUIRED to 2.2: DONE, 2.3: DONE, 2.4: DONE

ruby_2_4 r58629 merged revision(s) 58037.

Actions

Also available in: Atom PDF

Like0
Like0Like0Like0Like0Like0Like0Like0