From: Yusuke Endoh Date: 2010-03-31T01:52:46+09:00 Subject: [ruby-core:29149] [Feature #3021] Array#product should accept a block. Issue #3021 has been updated by Yusuke Endoh. Assigned to set to Yukihiro Matsumoto Hi, 2010/3/27 Marc-Andre Lafortune : > Array#permutation and #combination will yield to the given block, or else return an enumerator. > > I believe Array#product should have been designed the same way. > > Returning an enumerator today would break compatibility though. > > I suggest that Array#product(&block) yields to the block and returns self. This maintains compatibility while making it possible to produce an enumerable with my_array.to_enum(:product, ...) or to avoid building an intermediate array. Agreed! In fact, I suggested the similar change to let Array#product return an Enumerator. [ruby-dev:39277] Of course, it has a compatibility problem, and matz himself suggested exactly the same change as you. [ruby-dev:39306] -- Yusuke ENDOH ---------------------------------------- http://redmine.ruby-lang.org/issues/show/3021 ---------------------------------------- http://redmine.ruby-lang.org