From: marcandre-ruby-core@... Date: 2020-10-02T03:02:24+00:00 Subject: [ruby-core:100275] [Ruby master Feature#17208] Add `Set#compact` and `Set#compact!` methods Issue #17208 has been updated by marcandre (Marc-Andre Lafortune). shyouhei (Shyouhei Urabe) wrote in #note-2: > I like the feature, but isn't "Compact Set" a mathematical concept that refers to something different? It can, but the idea requires infinite sets, and all elements belonging to a topological space, I doubt many people would actually be confused. ---------------------------------------- Feature #17208: Add `Set#compact` and `Set#compact!` methods https://bugs.ruby-lang.org/issues/17208#change-87862 * 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/ Unsubscribe: