Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
[DOC] Tweaks for Array#zip
  • Loading branch information
BurdetteLamar committed Nov 7, 2024
commit 51c1552250e5b6c5711637bbdc1bf380940ad914
18 changes: 9 additions & 9 deletions array.c
Original file line number Diff line number Diff line change
Expand Up @@ -4373,18 +4373,14 @@ take_items(VALUE obj, long n)

/*
* call-seq:
* zip(*objects) -> new_array
* zip(*objects) {|other_array| ... } -> nil
* zip(*other_arrays) -> new_array
* zip(*other_arrays) {|other_array| ... } -> nil
*
* For an *object* in *objects* that is not an array,
* forms the the "other array" as <tt>object.to_ary</tt>, if defined,
* or as <tt>object.each.to_a</tt> otherwise.
*
* With no block given, combines +self+ with the collection of other arrays;
* With no block given, combines +self+ with the collection of +other_arrays+;
* returns a new array of sub-arrays.
*
* The returned object is an array of size <tt>objects.size + 1</tt>
* (that is, the count of other arrays plus one), and contains:
* Returns an array of size <tt>other_arrays.size + 1</tt>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think this is true? It returns an array of size self.size and each subarray is of size other_arrays.size + 1:

[1, 2].zip([3, 4], [5, 6], [7, 8]) # => [[1, 3, 5, 7], [2, 4, 6, 8]]

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changed.

* (that is, the count of other arrays plus one), that contains:
*
* - The _nth_ element of +self+.
* - The _nth_ element of each of the other arrays, as available.
Expand Down Expand Up @@ -4447,6 +4443,10 @@ take_items(VALUE obj, long n)
* [:c2, :b2, :a2],
* [:c3, :b3, :a3]]
*
* For an *object* in *other_arrays* that is not actually an array,
* forms the the "other array" as <tt>object.to_ary</tt>, if defined,
* or as <tt>object.each.to_a</tt> otherwise.
*
* Related: see {Methods for Converting}[rdoc-ref:Array@Methods+for+Converting].
*/

Expand Down