From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on dcvr.yhbt.net X-Spam-Level: X-Spam-Status: No, score=-3.8 required=3.0 tests=AWL,BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_PASS,UNPARSEABLE_RELAY shortcircuit=no autolearn=ham autolearn_force=no version=3.4.2 Received: from neon.ruby-lang.org (neon.ruby-lang.org [221.186.184.75]) by dcvr.yhbt.net (Postfix) with ESMTP id 3A8321F55B for ; Sat, 23 May 2020 02:15:58 +0000 (UTC) Received: from neon.ruby-lang.org (localhost [IPv6:::1]) by neon.ruby-lang.org (Postfix) with ESMTP id 3005C120969; Sat, 23 May 2020 11:15:33 +0900 (JST) Received: from xtrwkhkc.outbound-mail.sendgrid.net (xtrwkhkc.outbound-mail.sendgrid.net [167.89.16.28]) by neon.ruby-lang.org (Postfix) with ESMTPS id 03A97120928 for ; Sat, 23 May 2020 11:15:31 +0900 (JST) Received: by filterdrecv-p3iad2-8ddf98858-w5zgs with SMTP id filterdrecv-p3iad2-8ddf98858-w5zgs-17-5EC88759-2D 2020-05-23 02:15:53.824228411 +0000 UTC m=+5015308.118556001 Received: from herokuapp.com (unknown) by ismtpd0015p1iad1.sendgrid.net (SG) with ESMTP id s3c6s8KwSsuxDd97CfZMxw for ; Sat, 23 May 2020 02:15:53.689 +0000 (UTC) Date: Sat, 23 May 2020 02:15:53 +0000 (UTC) From: samuel@oriontransfer.net Message-ID: References: Mime-Version: 1.0 X-Redmine-MailingListIntegration-Message-Ids: 74278 X-Redmine-Project: ruby-master X-Redmine-Issue-Tracker: Bug X-Redmine-Issue-Id: 16908 X-Redmine-Issue-Author: ioquatix X-Redmine-Sender: ioquatix X-Mailer: Redmine X-Redmine-Host: bugs.ruby-lang.org X-Redmine-Site: Ruby Issue Tracking System X-Auto-Response-Suppress: All Auto-Submitted: auto-generated X-SG-EID: =?us-ascii?Q?cjxb6GWHefMLoR50bkJBcGo6DRiDl=2FNYcMZdY+Wj30R+PJFXx5gDGK78JMP0Fm?= =?us-ascii?Q?NtE45chDactnpr33sBxYj1KLBF+n2uhxFJjMEzn?= =?us-ascii?Q?sO+jPyho=2FArBCkyaR3agLoudSC28uR3omYX=2FDSi?= =?us-ascii?Q?PePcNQKDaOL35SCSB1blknBOkcSMXgBp0x=2FAN3l?= =?us-ascii?Q?8xwNZjg9R8VRPn5KTKxyXqpxFH3u6QSTkB81ScE?= =?us-ascii?Q?bj6MsTdyqULk=2FXBUg=3D?= To: ruby-core@ruby-lang.org X-ML-Name: ruby-core X-Mail-Count: 98486 Subject: [ruby-core:98486] [Ruby master Bug#16908] Strange behaviour of Hash#shift when used with `default_proc`. X-BeenThere: ruby-core@ruby-lang.org X-Mailman-Version: 2.1.15 Precedence: list Reply-To: Ruby developers List-Id: Ruby developers List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: ruby-core-bounces@ruby-lang.org Sender: "ruby-core" Issue #16908 has been reported by ioquatix (Samuel Williams). ---------------------------------------- Bug #16908: Strange behaviour of Hash#shift when used with `default_proc`. https://bugs.ruby-lang.org/issues/16908 * Author: ioquatix (Samuel Williams) * Status: Open * Priority: Normal * 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/