Project

General

Profile

ActionsLike0

Feature #15123

closed

Enumerable#compact proposal

Added by printercu (Max Melentiev) over 6 years ago. Updated over 5 years ago.

Status:
Feedback
Target version:
-
[ruby-core:89017]

Description

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?

Updated by marcandre (Marc-Andre Lafortune) over 6 years ago

  • Assignee set to matz (Yukihiro Matsumoto)
#6

Updated by nobu (Nobuyoshi Nakada) over 6 years ago

  • Tracker changed from Bug to Feature
  • Backport deleted (2.3: UNKNOWN, 2.4: UNKNOWN, 2.5: UNKNOWN)
#9

Updated by ko1 (Koichi Sasada) over 5 years ago

  • Status changed from Open to Feedback
ActionsLike0

Also available in: Atom PDF