From: Marc-Andre Lafortune Date: 2010-04-01T00:59:19+09:00 Subject: [ruby-dev:40887] Re: [Feature #2673] the length for an enumerator generated by Array#permutation and Array#combination Hi, On Wed, Mar 31, 2010 at 11:22 AM, Yukihiro Matsumoto wrote: > This propose has been suspended for 1.9.2 since the resule may not be > trustworthy considering the source modification after generating > enumerator.  I am not sure passing block is a good idea or not, yet. > It's not intuitive for me at the first glance. Thanks for the reply. Just another word in favor of a block: for some enumerators, calculating the overall size might non trivial (even though less costly then doing the actual enumeration). For this reason, I feel that there should not be a performance penalty when creating an Enumerator because the length need to be precalculated, even though very well might not be used. That's in addition to the fact that it might be wrong, if the source was modified in the meantime. This is why I feel that lazily calculating the length, whenever needed, is the best way to go, both for reasons of efficiency and correctness. I regret not having posted my ideas before, but hopefully we'll get Enumerator#length in 1.9.3... -- Marc-André