From c0d63ea09f41560f42c9d1f2605723fe5e6fa01c Mon Sep 17 00:00:00 2001 From: "Yukihiro \"Matz\" Matsumoto" Date: Wed, 17 Mar 2021 15:14:23 +0900 Subject: hash.c: `Hash#shift` to return `nil` when a hash is empty. It used to be return the default value if available, but it should ignore the default value for behavior consistency. CRuby will adopt this behavior too in the future. [ruby-bugs:16908] --- test/t/hash.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'test') diff --git a/test/t/hash.rb b/test/t/hash.rb index a5e51d83b..9bc2668ae 100644 --- a/test/t/hash.rb +++ b/test/t/hash.rb @@ -775,7 +775,7 @@ assert('Hash#shift', '15.2.13.4.24') do assert_equal(0, h.size) h.default = -456 - assert_equal(-456, h.shift) + assert_equal(nil, h.shift) assert_equal(0, h.size) h.freeze @@ -783,8 +783,8 @@ assert('Hash#shift', '15.2.13.4.24') do end h = Hash.new{|h, k| [h, k]} - assert_operator(h.shift, :eql?, [h, nil]) assert_equal(0, h.size) + assert_equal(nil, h.shift) end # Not ISO specified -- cgit v1.2.3