Skip to content

Commit 54a8318

Browse files
committed
* enum.c: added doc for Enumerable#zip
[fix rubyGH-985] Patch by @yui-knk * test/ruby/test_enum.rb: added tests for Enumerable#zip [fix rubyGH-985] Patch @yui-knk git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51526 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
1 parent 6114b0a commit 54a8318

File tree

3 files changed

+15
-1
lines changed

3 files changed

+15
-1
lines changed

ChangeLog

+7
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
1+
Tue Aug 11 10:48:16 2015 SHIBATA Hiroshi <hsbt@ruby-lang.org>
2+
3+
* enum.c: added doc for Enumerable#zip
4+
[fix GH-985] Patch by @yui-knk
5+
* test/ruby/test_enum.rb: added tests for Enumerable#zip
6+
[fix GH-985] Patch @yui-knk
7+
18
Tue Aug 11 10:33:26 2015 SHIBATA Hiroshi <hsbt@ruby-lang.org>
29

310
* vm_method.c: typo fix [fix GH-993][ci skip] Patch by @0x0dea

enum.c

+4
Original file line numberDiff line numberDiff line change
@@ -2454,6 +2454,10 @@ zip_i(RB_BLOCK_CALL_FUNC_ARGLIST(val, memoval))
24542454
* [1, 2].zip(a, b) #=> [[1, 4, 7], [2, 5, 8]]
24552455
* a.zip([1, 2], [8]) #=> [[4, 1, 8], [5, 2, nil], [6, nil, nil]]
24562456
*
2457+
* c = []
2458+
* a.zip(b) { |x, y| c << x + y } #=> nil
2459+
* c #=> [11, 13, 15]
2460+
*
24572461
*/
24582462

24592463
static VALUE

test/ruby/test_enum.rb

+4-1
Original file line numberDiff line numberDiff line change
@@ -434,8 +434,11 @@ def test_each_cons
434434

435435
def test_zip
436436
assert_equal([[1,1],[2,2],[3,3],[1,1],[2,2]], @obj.zip(@obj))
437+
assert_equal([["a",1],["b",2],["c",3]], ["a", "b", "c"].zip(@obj))
438+
437439
a = []
438-
@obj.zip([:a, :b, :c]) {|x,y| a << [x, y] }
440+
result = @obj.zip([:a, :b, :c]) {|x,y| a << [x, y] }
441+
assert_nil result
439442
assert_equal([[1,:a],[2,:b],[3,:c],[1,nil],[2,nil]], a)
440443

441444
a = []

0 commit comments

Comments
 (0)