From: daniel@...42.com Date: 2020-11-13T16:32:36+00:00 Subject: [ruby-core:100833] [Ruby master Feature#17312] New methods in Enumerable and Enumerator::Lazy: flatten, product, compact Issue #17312 has been updated by Dan0042 (Daniel DeLorme). What would be the interaction between Array#flatten and Enumerable#flatten ? It's a big compatibility problem if flatten recursively applies to any Enumerable object within an array. ```ruby x = Struct.new(:a).new(1) #=> # [[[x]]].flatten #=> [x] currently Enumerable === x #=> true x.to_a #=> [1] [[[x]]].flatten #=> [1] would be a problem ``` ---------------------------------------- Feature #17312: New methods in Enumerable and Enumerator::Lazy: flatten, product, compact https://bugs.ruby-lang.org/issues/17312#change-88475 * Author: zverok (Victor Shepelev) * Status: Open * Priority: Normal ---------------------------------------- (The offspring of #16987, which was too vague/philosophical) I propose to add to `Enumerable` and `Enumerator::Lazy` the following methods: * `compact` * `product` * `flatten` All of them can be performed with a one-way enumerator. All of them make sense for situations other than "just an array". All of them can be used for processing large sequences, and therefore meaningful to add to `Lazy`. -- https://bugs.ruby-lang.org/ Unsubscribe: