* array.c (rb_ary_delete): Array#delete to return deleted element.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@18527 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
matz 2008-08-12 09:12:24 +00:00
Родитель abef7fa890
Коммит e605839355
2 изменённых файлов: 10 добавлений и 2 удалений

Просмотреть файл

@ -70,6 +70,10 @@ Tue Aug 12 14:15:13 2008 Nobuyoshi Nakada <nobu@ruby-lang.org>
* ext/dl/cptr.c (rb_dlptr_s_to_ptr): fixed shadowing variable.
Tue Aug 12 10:25:14 2008 Yukihiro Matsumoto <matz@ruby-lang.org>
* array.c (rb_ary_delete): Array#delete to return deleted element.
Tue Aug 12 10:18:01 2008 Yukihiro Matsumoto <matz@ruby-lang.org>
* test/win32ole/test_err_in_callback.rb: do not require 'mkmf'

Просмотреть файл

@ -1747,12 +1747,16 @@ rb_ary_select(VALUE ary)
VALUE
rb_ary_delete(VALUE ary, VALUE item)
{
VALUE v = item;
long i1, i2;
for (i1 = i2 = 0; i1 < RARRAY_LEN(ary); i1++) {
VALUE e = RARRAY_PTR(ary)[i1];
if (rb_equal(e, item)) continue;
if (rb_equal(e, item)) {
v = e;
continue;
}
if (i1 != i2) {
rb_ary_store(ary, i2, e);
}
@ -1774,7 +1778,7 @@ rb_ary_delete(VALUE ary, VALUE item)
}
}
return item;
return v;
}
VALUE