From: grzegorz.jakubiak@... Date: 2018-09-14T19:43:44+00:00 Subject: [ruby-core:89019] [Ruby trunk Bug#15123] Enumerable#compact proposal 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/ Unsubscribe: