[#100689] [Ruby master Feature#17303] Make webrick to bundled gems or remove from stdlib — hsbt@...
Issue #17303 has been reported by hsbt (Hiroshi SHIBATA).
11 messages
2020/11/02
[#100852] [Ruby master Feature#17326] Add Kernel#must! to the standard library — zimmerman.jake@...
SXNzdWUgIzE3MzI2IGhhcyBiZWVuIHJlcG9ydGVkIGJ5IGpleiAoSmFrZSBaaW1tZXJtYW4pLg0K
24 messages
2020/11/14
[#100930] [Ruby master Feature#17333] Enumerable#many? — masafumi.o1988@...
Issue #17333 has been reported by okuramasafumi (Masafumi OKURA).
10 messages
2020/11/18
[#101071] [Ruby master Feature#17342] Hash#fetch_set — hunter_spawn@...
Issue #17342 has been reported by MaxLap (Maxime Lapointe).
26 messages
2020/11/25
[ruby-core:100717] [Ruby master Feature#17208] Add `Set#compact` and `Set#compact!` methods
From:
bozhidar@...
Date:
2020-11-05 09:41:30 UTC
List:
ruby-core #100717
Issue #17208 has been updated by bozhidar (Bozhidar Batsov).
I like the proposal. I also wonder if we shouldn't be able to able to reject nils at Set creation time, as nil rarely makes sense as a set value.
----------------------------------------
Feature #17208: Add `Set#compact` and `Set#compact!` methods
https://bugs.ruby-lang.org/issues/17208#change-88361
* 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: {1, "c", nil}>
set.compact! #=> #<Set: {1, "c"}>
set #=> #<Set: {1, "c"}>
set = Set[1, 'c'] #=> #<Set: {1, "c"}>
set.compact! #=> nil
set #=> #<Set: {1, "c"}>
```
`Set#compact`:
```ruby
# Returns a new Set containing all non-nil elements from self.
set = Set[1, 'c', nil] #=> #<Set: {1, "c", nil}>
set.compact #=> #<Set: {1, "c"}>
set #=> #<Set: {1, "c", nil}>
set = Set[1, 'c'] #=> #<Set: {1, "c"}>
set.compact #=> #<Set: {1, "c"}>
set #=> #<Set: {1, "c"}>
```
Pull Request ... https://github.com/ruby/ruby/pull/3617
--
https://bugs.ruby-lang.org/
Unsubscribe: <mailto:[email protected]?subject=unsubscribe>
<http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-core>