diff --git a/ChangeLog b/ChangeLog index c3b4afac43..3d84aeac96 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +Mon Apr 14 17:23:27 2008 Akinori MUSHA + + * hash.c (rb_hash_delete_if, rb_hash_reject_bang, env_delete_if, + env_reject_bang): Return an enumerator if no block is given. + Mon Apr 14 14:33:59 2008 Nobuyoshi Nakada * compile.c, compile.h (compile_debug): made runtime option. diff --git a/hash.c b/hash.c index 50fb4d7905..d9147d37e3 100644 --- a/hash.c +++ b/hash.c @@ -787,6 +787,7 @@ delete_if_i(VALUE key, VALUE value, VALUE hash) VALUE rb_hash_delete_if(VALUE hash) { + RETURN_ENUMERATOR(hash, 0, 0); rb_hash_modify(hash); rb_hash_foreach(hash, delete_if_i, hash); return hash; @@ -804,6 +805,8 @@ VALUE rb_hash_reject_bang(VALUE hash) { int n; + + RETURN_ENUMERATOR(hash, 0, 0); if (!RHASH(hash)->ntbl) return Qnil; n = RHASH(hash)->ntbl->num_entries; @@ -2142,12 +2145,13 @@ env_each_pair(VALUE ehash) } static VALUE -env_reject_bang(void) +env_reject_bang(VALUE ehash) { volatile VALUE keys; long i; int del = 0; + RETURN_ENUMERATOR(ehash, 0, 0); rb_secure(4); keys = env_keys(); for (i=0; i