зеркало из https://github.com/github/ruby.git
* enum.c: added doc for Enumerable#zip
[fix GH-985] Patch by @yui-knk * test/ruby/test_enum.rb: added tests for Enumerable#zip [fix GH-985] Patch @yui-knk git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51526 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
Родитель
6114b0a4f9
Коммит
54a8318ecd
|
@ -1,3 +1,10 @@
|
|||
Tue Aug 11 10:48:16 2015 SHIBATA Hiroshi <hsbt@ruby-lang.org>
|
||||
|
||||
* enum.c: added doc for Enumerable#zip
|
||||
[fix GH-985] Patch by @yui-knk
|
||||
* test/ruby/test_enum.rb: added tests for Enumerable#zip
|
||||
[fix GH-985] Patch @yui-knk
|
||||
|
||||
Tue Aug 11 10:33:26 2015 SHIBATA Hiroshi <hsbt@ruby-lang.org>
|
||||
|
||||
* vm_method.c: typo fix [fix GH-993][ci skip] Patch by @0x0dea
|
||||
|
|
4
enum.c
4
enum.c
|
@ -2454,6 +2454,10 @@ zip_i(RB_BLOCK_CALL_FUNC_ARGLIST(val, memoval))
|
|||
* [1, 2].zip(a, b) #=> [[1, 4, 7], [2, 5, 8]]
|
||||
* a.zip([1, 2], [8]) #=> [[4, 1, 8], [5, 2, nil], [6, nil, nil]]
|
||||
*
|
||||
* c = []
|
||||
* a.zip(b) { |x, y| c << x + y } #=> nil
|
||||
* c #=> [11, 13, 15]
|
||||
*
|
||||
*/
|
||||
|
||||
static VALUE
|
||||
|
|
|
@ -434,8 +434,11 @@ class TestEnumerable < Test::Unit::TestCase
|
|||
|
||||
def test_zip
|
||||
assert_equal([[1,1],[2,2],[3,3],[1,1],[2,2]], @obj.zip(@obj))
|
||||
assert_equal([["a",1],["b",2],["c",3]], ["a", "b", "c"].zip(@obj))
|
||||
|
||||
a = []
|
||||
@obj.zip([:a, :b, :c]) {|x,y| a << [x, y] }
|
||||
result = @obj.zip([:a, :b, :c]) {|x,y| a << [x, y] }
|
||||
assert_nil result
|
||||
assert_equal([[1,:a],[2,:b],[3,:c],[1,nil],[2,nil]], a)
|
||||
|
||||
a = []
|
||||
|
|
Загрузка…
Ссылка в новой задаче