* [ruby-core:89017] [Ruby trunk Bug#15123] Enumerable#compact proposal
[not found] <redmine.issue-15123.20180914173004@ruby-lang.org>
@ 2018-09-14 17:30 ` melentievm
2018-09-14 19:43 ` [ruby-core:89019] " grzegorz.jakubiak
` (7 subsequent siblings)
8 siblings, 0 replies; 9+ messages in thread
From: melentievm @ 2018-09-14 17:30 UTC (permalink / raw)
To: ruby-core
Issue #15123 has been reported by printercu (Max Melentiev).
----------------------------------------
Bug #15123: Enumerable#compact proposal
https://bugs.ruby-lang.org/issues/15123
* Author: printercu (Max Melentiev)
* Status: Open
* Priority: Normal
* Assignee:
* Target version:
* ruby -v:
* Backport: 2.3: UNKNOWN, 2.4: UNKNOWN, 2.5: UNKNOWN
----------------------------------------
Hi!
While Enumerable does not provide `#compact` method, it requires changing code in some cases to substitute array with enumerator.
For example, to reduce memory usage it's usual to change `large_array.map { to_heavy_object }.chained_methods` to `large_array.lazy...`. However if `chained_methods` contains `compact`, this change will fail. Replacing `compact` with `reject(&:nil?)` fixes it.
What do you think about adding `#compact` to Enumerable?
--
https://bugs.ruby-lang.org/
^ permalink raw reply [flat|nested] 9+ messages in thread
* [ruby-core:89019] [Ruby trunk Bug#15123] Enumerable#compact proposal
[not found] <redmine.issue-15123.20180914173004@ruby-lang.org>
2018-09-14 17:30 ` [ruby-core:89017] [Ruby trunk Bug#15123] Enumerable#compact proposal melentievm
@ 2018-09-14 19:43 ` grzegorz.jakubiak
2018-09-15 2:37 ` [ruby-core:89023] " ruby-core
` (6 subsequent siblings)
8 siblings, 0 replies; 9+ messages in thread
From: grzegorz.jakubiak @ 2018-09-14 19:43 UTC (permalink / raw)
To: ruby-core
Issue #15123 has been updated by greggzst (Grzegorz Jakubiak).
I'm in favor of this proposal. It simplifies working with large and small collections so one doesn't have to remember that can't use `#compact` when enumerator is returned and have to fall back to `#reject(:nil?)`.
----------------------------------------
Bug #15123: Enumerable#compact proposal
https://bugs.ruby-lang.org/issues/15123#change-74045
* Author: printercu (Max Melentiev)
* Status: Open
* Priority: Normal
* Assignee:
* Target version:
* ruby -v:
* Backport: 2.3: UNKNOWN, 2.4: UNKNOWN, 2.5: UNKNOWN
----------------------------------------
Hi!
While Enumerable does not provide `#compact` method, it requires changing code in some cases to substitute array with enumerator.
For example, to reduce memory usage it's usual to change `large_array.map { to_heavy_object }.chained_methods` to `large_array.lazy...`. However if `chained_methods` contains `compact`, this change will fail. Replacing `compact` with `reject(&:nil?)` fixes it.
What do you think about adding `#compact` to Enumerable?
--
https://bugs.ruby-lang.org/
^ permalink raw reply [flat|nested] 9+ messages in thread
* [ruby-core:89023] [Ruby trunk Bug#15123] Enumerable#compact proposal
[not found] <redmine.issue-15123.20180914173004@ruby-lang.org>
2018-09-14 17:30 ` [ruby-core:89017] [Ruby trunk Bug#15123] Enumerable#compact proposal melentievm
2018-09-14 19:43 ` [ruby-core:89019] " grzegorz.jakubiak
@ 2018-09-15 2:37 ` ruby-core
2018-09-15 7:46 ` [ruby-core:89026] " eregontp
` (5 subsequent siblings)
8 siblings, 0 replies; 9+ messages in thread
From: ruby-core @ 2018-09-15 2:37 UTC (permalink / raw)
To: ruby-core
Issue #15123 has been updated by marcandre (Marc-Andre Lafortune).
Assignee set to matz (Yukihiro Matsumoto)
Proposal seems acceptable to me.
Just to be clear: I imagine that `Lazy#compact` would still be lazy. Also `compact` is roughly `select(&:itself)`, not `reject(&:nil?)` which would wrongly reject `false`.
----------------------------------------
Bug #15123: Enumerable#compact proposal
https://bugs.ruby-lang.org/issues/15123#change-74049
* Author: printercu (Max Melentiev)
* Status: Open
* Priority: Normal
* Assignee: matz (Yukihiro Matsumoto)
* Target version:
* ruby -v:
* Backport: 2.3: UNKNOWN, 2.4: UNKNOWN, 2.5: UNKNOWN
----------------------------------------
Hi!
While Enumerable does not provide `#compact` method, it requires changing code in some cases to substitute array with enumerator.
For example, to reduce memory usage it's usual to change `large_array.map { to_heavy_object }.chained_methods` to `large_array.lazy...`. However if `chained_methods` contains `compact`, this change will fail. Replacing `compact` with `reject(&:nil?)` fixes it.
What do you think about adding `#compact` to Enumerable?
--
https://bugs.ruby-lang.org/
^ permalink raw reply [flat|nested] 9+ messages in thread
* [ruby-core:89026] [Ruby trunk Bug#15123] Enumerable#compact proposal
[not found] <redmine.issue-15123.20180914173004@ruby-lang.org>
` (2 preceding siblings ...)
2018-09-15 2:37 ` [ruby-core:89023] " ruby-core
@ 2018-09-15 7:46 ` eregontp
2018-09-15 11:06 ` [ruby-core:89029] " shevegen
` (4 subsequent siblings)
8 siblings, 0 replies; 9+ messages in thread
From: eregontp @ 2018-09-15 7:46 UTC (permalink / raw)
To: ruby-core
Issue #15123 has been updated by Eregon (Benoit Daloze).
marcandre (Marc-Andre Lafortune) wrote:
> Also `compact` is roughly `select(&:itself)`, not `reject(&:nil?)` which would wrongly keep `false`.
No, #compact only removes `nil`: `["a" ,false ,nil].compact` => `["a", false]`.
----------------------------------------
Bug #15123: Enumerable#compact proposal
https://bugs.ruby-lang.org/issues/15123#change-74051
* Author: printercu (Max Melentiev)
* Status: Open
* Priority: Normal
* Assignee: matz (Yukihiro Matsumoto)
* Target version:
* ruby -v:
* Backport: 2.3: UNKNOWN, 2.4: UNKNOWN, 2.5: UNKNOWN
----------------------------------------
Hi!
While Enumerable does not provide `#compact` method, it requires changing code in some cases to substitute array with enumerator.
For example, to reduce memory usage it's usual to change `large_array.map { to_heavy_object }.chained_methods` to `large_array.lazy...`. However if `chained_methods` contains `compact`, this change will fail. Replacing `compact` with `reject(&:nil?)` fixes it.
What do you think about adding `#compact` to Enumerable?
--
https://bugs.ruby-lang.org/
^ permalink raw reply [flat|nested] 9+ messages in thread
* [ruby-core:89029] [Ruby trunk Bug#15123] Enumerable#compact proposal
[not found] <redmine.issue-15123.20180914173004@ruby-lang.org>
` (3 preceding siblings ...)
2018-09-15 7:46 ` [ruby-core:89026] " eregontp
@ 2018-09-15 11:06 ` shevegen
2018-09-15 14:38 ` [ruby-core:89031] " ruby-core
` (3 subsequent siblings)
8 siblings, 0 replies; 9+ messages in thread
From: shevegen @ 2018-09-15 11:06 UTC (permalink / raw)
To: ruby-core
Issue #15123 has been updated by shevegen (Robert A. Heiler).
I think if the meaning is consistent (e. g. .compact meaning to eliminate
nil values from a given collection) then this seems ok. Perhaps this could
be added for the next developer meeting.
----------------------------------------
Bug #15123: Enumerable#compact proposal
https://bugs.ruby-lang.org/issues/15123#change-74053
* Author: printercu (Max Melentiev)
* Status: Open
* Priority: Normal
* Assignee: matz (Yukihiro Matsumoto)
* Target version:
* ruby -v:
* Backport: 2.3: UNKNOWN, 2.4: UNKNOWN, 2.5: UNKNOWN
----------------------------------------
Hi!
While Enumerable does not provide `#compact` method, it requires changing code in some cases to substitute array with enumerator.
For example, to reduce memory usage it's usual to change `large_array.map { to_heavy_object }.chained_methods` to `large_array.lazy...`. However if `chained_methods` contains `compact`, this change will fail. Replacing `compact` with `reject(&:nil?)` fixes it.
What do you think about adding `#compact` to Enumerable?
--
https://bugs.ruby-lang.org/
^ permalink raw reply [flat|nested] 9+ messages in thread
* [ruby-core:89031] [Ruby trunk Bug#15123] Enumerable#compact proposal
[not found] <redmine.issue-15123.20180914173004@ruby-lang.org>
` (4 preceding siblings ...)
2018-09-15 11:06 ` [ruby-core:89029] " shevegen
@ 2018-09-15 14:38 ` ruby-core
2019-05-20 7:23 ` [ruby-core:92729] [Ruby trunk Feature#15123] " shyouhei
` (2 subsequent siblings)
8 siblings, 0 replies; 9+ messages in thread
From: ruby-core @ 2018-09-15 14:38 UTC (permalink / raw)
To: ruby-core
Issue #15123 has been updated by marcandre (Marc-Andre Lafortune).
Eregon (Benoit Daloze) wrote:
> No, #compact only removes `nil`: `["a" ,false ,nil].compact` => `["a", false]`.
Lol, ouch, not sure how I could be so confused when I wrote that, sorry!
----------------------------------------
Bug #15123: Enumerable#compact proposal
https://bugs.ruby-lang.org/issues/15123#change-74055
* Author: printercu (Max Melentiev)
* Status: Open
* Priority: Normal
* Assignee: matz (Yukihiro Matsumoto)
* Target version:
* ruby -v:
* Backport: 2.3: UNKNOWN, 2.4: UNKNOWN, 2.5: UNKNOWN
----------------------------------------
Hi!
While Enumerable does not provide `#compact` method, it requires changing code in some cases to substitute array with enumerator.
For example, to reduce memory usage it's usual to change `large_array.map { to_heavy_object }.chained_methods` to `large_array.lazy...`. However if `chained_methods` contains `compact`, this change will fail. Replacing `compact` with `reject(&:nil?)` fixes it.
What do you think about adding `#compact` to Enumerable?
--
https://bugs.ruby-lang.org/
^ permalink raw reply [flat|nested] 9+ messages in thread
* [ruby-core:92729] [Ruby trunk Feature#15123] Enumerable#compact proposal
[not found] <redmine.issue-15123.20180914173004@ruby-lang.org>
` (5 preceding siblings ...)
2018-09-15 14:38 ` [ruby-core:89031] " ruby-core
@ 2019-05-20 7:23 ` shyouhei
2019-09-02 5:28 ` [ruby-core:94721] [Ruby master " matz
2019-10-30 19:30 ` [ruby-core:95592] " keystonelemur
8 siblings, 0 replies; 9+ messages in thread
From: shyouhei @ 2019-05-20 7:23 UTC (permalink / raw)
To: ruby-core
Issue #15123 has been updated by shyouhei (Shyouhei Urabe).
Just leaving a comment that I wanted this method in my pet project just now. So +1.
----------------------------------------
Feature #15123: Enumerable#compact proposal
https://bugs.ruby-lang.org/issues/15123#change-78088
* Author: printercu (Max Melentiev)
* Status: Open
* Priority: Normal
* Assignee: matz (Yukihiro Matsumoto)
* Target version:
----------------------------------------
Hi!
While Enumerable does not provide `#compact` method, it requires changing code in some cases to substitute array with enumerator.
For example, to reduce memory usage it's usual to change `large_array.map { to_heavy_object }.chained_methods` to `large_array.lazy...`. However if `chained_methods` contains `compact`, this change will fail. Replacing `compact` with `reject(&:nil?)` fixes it.
What do you think about adding `#compact` to Enumerable?
--
https://bugs.ruby-lang.org/
^ permalink raw reply [flat|nested] 9+ messages in thread
* [ruby-core:94721] [Ruby master Feature#15123] Enumerable#compact proposal
[not found] <redmine.issue-15123.20180914173004@ruby-lang.org>
` (6 preceding siblings ...)
2019-05-20 7:23 ` [ruby-core:92729] [Ruby trunk Feature#15123] " shyouhei
@ 2019-09-02 5:28 ` matz
2019-10-30 19:30 ` [ruby-core:95592] " keystonelemur
8 siblings, 0 replies; 9+ messages in thread
From: matz @ 2019-09-02 5:28 UTC (permalink / raw)
To: ruby-core
Issue #15123 has been updated by matz (Yukihiro Matsumoto).
I don't see enough demand for `compact` where we have `reject(&:nil?)`. Any additional use-case?
Matz.
----------------------------------------
Feature #15123: Enumerable#compact proposal
https://bugs.ruby-lang.org/issues/15123#change-81334
* Author: printercu (Max Melentiev)
* Status: Open
* Priority: Normal
* Assignee: matz (Yukihiro Matsumoto)
* Target version:
----------------------------------------
Hi!
While Enumerable does not provide `#compact` method, it requires changing code in some cases to substitute array with enumerator.
For example, to reduce memory usage it's usual to change `large_array.map { to_heavy_object }.chained_methods` to `large_array.lazy...`. However if `chained_methods` contains `compact`, this change will fail. Replacing `compact` with `reject(&:nil?)` fixes it.
What do you think about adding `#compact` to Enumerable?
--
https://bugs.ruby-lang.org/
^ permalink raw reply [flat|nested] 9+ messages in thread
* [ruby-core:95592] [Ruby master Feature#15123] Enumerable#compact proposal
[not found] <redmine.issue-15123.20180914173004@ruby-lang.org>
` (7 preceding siblings ...)
2019-09-02 5:28 ` [ruby-core:94721] [Ruby master " matz
@ 2019-10-30 19:30 ` keystonelemur
8 siblings, 0 replies; 9+ messages in thread
From: keystonelemur @ 2019-10-30 19:30 UTC (permalink / raw)
To: ruby-core
Issue #15123 has been updated by baweaver (Brandon Weaver).
@matz: Its presence in Array and Hash make it more of a common interface that I could see being defined for Enumerable in general, though the immediate usecases are around Lazy. As mentioned above, sometimes one wants to use Enumerators directly or returns one from an Enumerable method which can cause some conflicts of available methods.
I believe it could be considered surprising that `compact` does not necessarily work with all collection-like types.
----------------------------------------
Feature #15123: Enumerable#compact proposal
https://bugs.ruby-lang.org/issues/15123#change-82382
* Author: printercu (Max Melentiev)
* Status: Feedback
* Priority: Normal
* Assignee: matz (Yukihiro Matsumoto)
* Target version:
----------------------------------------
Hi!
While Enumerable does not provide `#compact` method, it requires changing code in some cases to substitute array with enumerator.
For example, to reduce memory usage it's usual to change `large_array.map { to_heavy_object }.chained_methods` to `large_array.lazy...`. However if `chained_methods` contains `compact`, this change will fail. Replacing `compact` with `reject(&:nil?)` fixes it.
What do you think about adding `#compact` to Enumerable?
--
https://bugs.ruby-lang.org/
^ permalink raw reply [flat|nested] 9+ messages in thread