Project

General

Profile

Actions

Bug #16908

closed

Strange behaviour of Hash#shift when used with `default_proc`.

Added by ioquatix (Samuel Williams) over 4 years ago. Updated almost 3 years ago.

Status:
Closed
Target version:
-
[ruby-core:98486]

Description

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].

Actions

Also available in: Atom PDF

Like0
Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0