diff options
author | Jeremy Evans <code@jeremyevans.net> | 2021-12-27 14:41:43 -0800 |
---|---|---|
committer | Jeremy Evans <code@jeremyevans.net> | 2022-01-14 12:17:57 -0800 |
commit | a93cc3e23b4044762e80820fc7a45606587e11db (patch) | |
tree | be06c72142c01f40013a6f58bc334a4f907bea88 /hash.c | |
parent | 6b7eff90860d4fb4db01ec4d1f522afa6d809632 (diff) | |
download | ruby-a93cc3e23b4044762e80820fc7a45606587e11db.tar.gz |
Make Hash#shift return nil for empty hash
Fixes [Bug #16908]
Diffstat (limited to 'hash.c')
-rw-r--r-- | hash.c | 7 |
1 files changed, 3 insertions, 4 deletions
@@ -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 |