From: "mame (Yusuke Endoh)" Date: 2022-01-14T03:01:23+00:00 Subject: [ruby-core:107113] [Ruby master Bug#16908] Strange behaviour of Hash#shift when used with `default_proc`. Issue #16908 has been updated by mame (Yusuke Endoh). Assignee set to jeremyevans0 (Jeremy Evans) Status changed from Open to Assigned Jeremy's approach (make Hash#shift return nil if the hash is empty) was approved by @matz. ---------------------------------------- Bug #16908: Strange behaviour of Hash#shift when used with `default_proc`. https://bugs.ruby-lang.org/issues/16908#change-95959 * Author: ioquatix (Samuel Williams) * Status: Assigned * Priority: Normal * Assignee: jeremyevans0 (Jeremy Evans) * ruby -v: 2.7.0 * Backport: 2.5: UNKNOWN, 2.6: UNKNOWN, 2.7: UNKNOWN ---------------------------------------- I don't have any strong opinion about this, but I observed the following behaviour which I thought was confusing. Maybe it's okay, or maybe we should change it to be more consistent. ``` hash = Hash.new{|k,v| k[v] = 0} hash.shift # => 0 hash.shift # => [nil, 0] ``` My feeling was, both cases should return `[nil, 0]`. -- https://bugs.ruby-lang.org/ Unsubscribe: