зеркало из https://github.com/github/ruby.git
Revert r63030
* array.c (rb_ary_collect): no longer splat sole array for lambda. [ruby-core:89734] [Bug #15285] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@65923 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
Родитель
6a65f2b1e4
Коммит
b309975a91
2
array.c
2
array.c
|
@ -3010,7 +3010,7 @@ rb_ary_collect(VALUE ary)
|
|||
RETURN_SIZED_ENUMERATOR(ary, 0, 0, ary_enum_length);
|
||||
collect = rb_ary_new2(RARRAY_LEN(ary));
|
||||
for (i = 0; i < RARRAY_LEN(ary); i++) {
|
||||
rb_ary_push(collect, rb_yield_force_blockarg(RARRAY_AREF(ary, i)));
|
||||
rb_ary_push(collect, rb_yield(RARRAY_AREF(ary, i)));
|
||||
}
|
||||
return collect;
|
||||
}
|
||||
|
|
|
@ -549,7 +549,9 @@ class TestArray < Test::Unit::TestCase
|
|||
|
||||
assert_kind_of Enumerator, @cls[1, 2, 3].collect
|
||||
|
||||
assert_equal([[1, 2, 3]], [[1, 2, 3]].collect(&->(a, b, c) {[a, b, c]}))
|
||||
assert_raise(ArgumentError) {
|
||||
assert_equal([[1, 2, 3]], [[1, 2, 3]].collect(&->(a, b, c) {[a, b, c]}))
|
||||
}
|
||||
end
|
||||
|
||||
# also update map!
|
||||
|
|
Загрузка…
Ссылка в новой задаче