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-ASN: AS4713 221.184.0.0/13 X-Spam-Status: No, score=-3.9 required=3.0 tests=AWL,BAYES_00, MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED,SPF_HELO_NONE,SPF_PASS 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 C0AB51F4BD for ; Tue, 1 Oct 2019 03:34:39 +0000 (UTC) Received: from neon.ruby-lang.org (localhost [IPv6:::1]) by neon.ruby-lang.org (Postfix) with ESMTP id 8D4E51209A7; Tue, 1 Oct 2019 12:34:31 +0900 (JST) Received: from o1678948x4.outbound-mail.sendgrid.net (o1678948x4.outbound-mail.sendgrid.net [167.89.48.4]) by neon.ruby-lang.org (Postfix) with ESMTPS id CA4CA12099E for ; Tue, 1 Oct 2019 12:34:28 +0900 (JST) Received: by filter0177p3mdw1.sendgrid.net with SMTP id filter0177p3mdw1-21832-5D92C947-D 2019-10-01 03:34:31.106507393 +0000 UTC m=+629182.777543743 Received: from herokuapp.com (unknown [54.173.8.255]) by ismtpd0071p1mdw1.sendgrid.net (SG) with ESMTP id PFot9waxRp2ueQFUPgDYIw for ; Tue, 01 Oct 2019 03:34:31.133 +0000 (UTC) Date: Tue, 01 Oct 2019 03:34:31 +0000 (UTC) From: nobu@ruby-lang.org Message-ID: References: Mime-Version: 1.0 X-Redmine-MailingListIntegration-Message-Ids: 70721 X-Redmine-Project: ruby-trunk X-Redmine-Issue-Id: 16173 X-Redmine-Issue-Author: burdettelamar@yahoo.com X-Redmine-Sender: nobu 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?q8Dly+pU2+3ektTtZVXgZtbJPXwqo7p86jCsvYTW4Byr4T5ZJf6bxjnu1F3JTE?= =?us-ascii?Q?Ck45MGymtikeCNSuA+5zBu2XXe=2FYIJWhqQKXHxY?= =?us-ascii?Q?fl6nvYdi94F8ugILF73Dwihp4yckfiBCbbyApQN?= =?us-ascii?Q?WKpqkf4N9+c0VcEAWliazCY9MXbDrX8d=2FF5gZoS?= =?us-ascii?Q?Dcf76ldVFtbSaB4ZPvVfwNwlAtfNVacDV0g=3D=3D?= To: ruby-core@ruby-lang.org X-ML-Name: ruby-core X-Mail-Count: 95166 Subject: [ruby-core:95166] [Ruby master Bug#16173] ENV.delete returns nil when name does not exist and block given 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 #16173 has been updated by nobu (Nobuyoshi Nakada). burdettelamar@yahoo.com (Burdette Lamar) wrote: > Thanks, @alanwu. I'm refreshing diff.txt with more fulsome documentation, along with enhanced testing. Thank you for the patch. ```diff + * Deletes the environment variable for +name+ if it exists (ignoring the block, if given); returns +nil+: + * ENV.delete('LINES') # => '300' + * ENV.delete('COLUMNS') { |name| fail 'boo' } # => '120' ``` It should return the old value, not `nil`. ```diff + * Calls the block and returns +nil+ if the environment variable does not exist and block given: + * ENV.delete('NOSUCH') { |name| } # => nil ``` Non-empty block and non-nil result feels better to me. ---------------------------------------- Bug #16173: ENV.delete returns nil when name does not exist and block given https://bugs.ruby-lang.org/issues/16173#change-81803 * Author: burdettelamar@yahoo.com (Burdette Lamar) * Status: Open * Priority: Normal * Assignee: * Target version: * ruby -v: ruby 2.6.4p104 (2019-08-28 revision 67798) [x64-mingw32] * Backport: 2.5: UNKNOWN, 2.6: UNKNOWN ---------------------------------------- Attached diff.txt: * ENV.delete for nonexistent name and block given: * Test enhanced to verify return value is nil. * Documentation corrected to say that return value is nil, not value. ---Files-------------------------------- diff.txt (2.22 KB) -- https://bugs.ruby-lang.org/