summaryrefslogtreecommitdiff
path: root/hash.c
diff options
context:
space:
mode:
authorJeremy Evans <code@jeremyevans.net>2021-12-27 14:41:43 -0800
committerJeremy Evans <code@jeremyevans.net>2022-01-14 12:17:57 -0800
commita93cc3e23b4044762e80820fc7a45606587e11db (patch)
treebe06c72142c01f40013a6f58bc334a4f907bea88 /hash.c
parent6b7eff90860d4fb4db01ec4d1f522afa6d809632 (diff)
downloadruby-a93cc3e23b4044762e80820fc7a45606587e11db.tar.gz
Make Hash#shift return nil for empty hash
Fixes [Bug #16908]
Diffstat (limited to 'hash.c')
-rw-r--r--hash.c7
1 files changed, 3 insertions, 4 deletions
diff --git a/hash.c b/hash.c
index 9b1f762414..f032ef642a 100644
--- a/hash.c
+++ b/hash.c
@@ -2445,7 +2445,7 @@ shift_i_safe(VALUE key, VALUE value, VALUE arg)
/*
* call-seq:
- * hash.shift -> [key, value] or default_value
+ * hash.shift -> [key, value] or nil
*
* Removes the first hash entry
* (see {Entry Order}[#class-Hash-label-Entry+Order]);
@@ -2454,8 +2454,7 @@ shift_i_safe(VALUE key, VALUE value, VALUE arg)
* h.shift # => [:foo, 0]
* h # => {:bar=>1, :baz=>2}
*
- * Returns the default value if the hash is empty
- * (see {Default Values}[#class-Hash-label-Default+Values]).
+ * Returns nil if the hash is empty.
*/
static VALUE
@@ -2494,7 +2493,7 @@ rb_hash_shift(VALUE hash)
}
}
}
- return rb_hash_default_value(hash, Qnil);
+ return Qnil;
}
static int