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=-2.3 required=3.0 tests=AWL,BAYES_00, DKIM_ADSP_CUSTOM_MED,FORGED_GMAIL_RCVD,FREEMAIL_FORGED_FROMDOMAIN, FREEMAIL_FROM,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, RCVD_IN_DNSWL_MED,SPF_HELO_NONE,SPF_PASS,UNPARSEABLE_RELAY shortcircuit=no autolearn=no 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 A81341F4B4 for ; Thu, 1 Oct 2020 19:32:16 +0000 (UTC) Received: from neon.ruby-lang.org (localhost [IPv6:::1]) by neon.ruby-lang.org (Postfix) with ESMTP id A30C2120AFE; Fri, 2 Oct 2020 04:31:30 +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 9D83A120AE4 for ; Fri, 2 Oct 2020 04:31:28 +0900 (JST) Received: by filterdrecv-p3mdw1-5dd6bc5999-fr7kl with SMTP id filterdrecv-p3mdw1-5dd6bc5999-fr7kl-18-5F762EB1-88 2020-10-01 19:32:01.792802533 +0000 UTC m=+855205.912024196 Received: from herokuapp.com (unknown) by ismtpd0089p1iad2.sendgrid.net (SG) with ESMTP id TxxVyEeuTFmUE3YsBbb1dw for ; Thu, 01 Oct 2020 19:32:01.697 +0000 (UTC) Date: Thu, 01 Oct 2020 19:32:01 +0000 (UTC) From: koic.ito@gmail.com Message-ID: References: Mime-Version: 1.0 X-Redmine-MailingListIntegration-Message-Ids: 76100 X-Redmine-Project: ruby-master X-Redmine-Issue-Tracker: Feature X-Redmine-Issue-Id: 17208 X-Redmine-Issue-Author: koic X-Redmine-Sender: koic 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?a8a4ByxDnLEDxCazS6Dj0L=2Fc7dlmjHjOOToWL2oOooxZmmEOqNOW7ul9IkBlFH?= =?us-ascii?Q?8et0HQKBRPd2kcOgKiDPwnDxhBGCmLtT9Rb4=2F=2F3?= =?us-ascii?Q?sUWKfLdo+uqwC20pYFsmm8hZ4VBZrU3l=2FV6lWCm?= =?us-ascii?Q?tyCoaUcnLpaa4xRGwCfMshxJnKmQZkhnBE11w9Y?= =?us-ascii?Q?ztVuuVI3FOPVr1NCitAABVABvF5QDBqXSEHnR4m?= =?us-ascii?Q?+Hst8pA43SW0vRo5A=3D?= To: ruby-core@ruby-lang.org X-ML-Name: ruby-core X-Mail-Count: 100259 Subject: [ruby-core:100259] [Ruby master Feature#17208] Add `Set#compact` and `Set#compact!` methods 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 #17208 has been reported by koic (Koichi ITO). ---------------------------------------- Feature #17208: Add `Set#compact` and `Set#compact!` methods https://bugs.ruby-lang.org/issues/17208 * Author: koic (Koichi ITO) * Status: Open * Priority: Normal ---------------------------------------- This is a proposal to add `compact` and `compact!` methods already owned by `Array` and `Hash` to `Set`. - `Array#compact` and `Array#compact!` has been around for a long time. - `Hash#compact` has `Hash#compact!` been added since Ruby 2.4 ... https://bugs.ruby-lang.org/issues/11818 - There is `Set` in collection libraries other than `Array` and `Hash`. But `Set` doesn't have `compact` and `compact!` methods. It behaves the same as `compact` and `compact!` methods of `Array` and `Hash` as follows. `Set#compact!`: ```ruby # Removes all nil elements from self. Returns self if any elements removed, otherwise nil. set = Set[1, 'c', nil] #=> # set.compact! #=> # set #=> # set = Set[1, 'c'] #=> # set.compact! #=> nil set #=> # ``` `Set#compact`: ```ruby # Returns a new Set containing all non-nil elements from self. set = Set[1, 'c', nil] #=> # set.compact #=> # set #=> # set = Set[1, 'c'] #=> # set.compact #=> # set #=> # ``` Pull Request ... https://github.com/ruby/ruby/pull/3617 -- https://bugs.ruby-lang.org/