diff options
-rw-r--r-- | ChangeLog | 4 | ||||
-rw-r--r-- | array.c | 8 |
2 files changed, 10 insertions, 2 deletions
@@ -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 |