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.9 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 A1B3C1F4B4 for ; Thu, 1 Oct 2020 22:24:54 +0000 (UTC) Received: from neon.ruby-lang.org (localhost [IPv6:::1]) by neon.ruby-lang.org (Postfix) with ESMTP id 40C9F1209FD; Fri, 2 Oct 2020 07:24:18 +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 4ADA212099F for ; Fri, 2 Oct 2020 07:24:16 +0900 (JST) Received: by filterdrecv-p3mdw1-5dd6bc5999-kftgf with SMTP id filterdrecv-p3mdw1-5dd6bc5999-kftgf-16-5F765731-1A 2020-10-01 22:24:49.514550858 +0000 UTC m=+865576.999494660 Received: from herokuapp.com (unknown) by geopod-ismtpd-6-7 (SG) with ESMTP id kNJbYxd7RfeYCQiH-q9G4w for ; Thu, 01 Oct 2020 22:24:49.433 +0000 (UTC) Date: Thu, 01 Oct 2020 22:24:49 +0000 (UTC) From: marcandre-ruby-core@marc-andre.ca Message-ID: References: Mime-Version: 1.0 X-Redmine-MailingListIntegration-Message-Ids: 76109 X-Redmine-Project: ruby-master X-Redmine-Issue-Tracker: Feature X-Redmine-Issue-Id: 17208 X-Redmine-Issue-Author: koic X-Redmine-Sender: marcandre 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?6=2FIMxCQLDposcQf5wmbDAtfaKduBAO0bKyhL3BGZtMQ5q7K2TvpbN6A7JIyt9E?= =?us-ascii?Q?aOKrCzchNADygN8qbefRftQjsDElm0PmLqxiD9x?= =?us-ascii?Q?KkgIqWdiRhRue=2FLamiDCAzem8ovMUfh4B9+Q+Wa?= =?us-ascii?Q?aB3RcTcfg7c9YdXcghTbRCOSi=2Fps2GiF3Je971v?= =?us-ascii?Q?oRYPSeAColx1xMzRBhr+GA=2FmzVa8+gh64UYvU49?= =?us-ascii?Q?akZ9BmD6d597ISBGIWK54iXq+nmZPcWdPVWgvA?= To: ruby-core@ruby-lang.org X-ML-Name: ruby-core X-Mail-Count: 100267 Subject: [ruby-core:100267] [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 updated by marcandre (Marc-Andre Lafortune). I second ---------------------------------------- Feature #17208: Add `Set#compact` and `Set#compact!` methods https://bugs.ruby-lang.org/issues/17208#change-87854 * 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/