From: Yukihiro Matsumoto Date: 2010-08-20T13:25:37+09:00 Subject: [ruby-core:31791] Re: [Feature #3715] Enumerator#size and #size= Hi, In message "Re: [ruby-core:31785] [Feature #3715] Enumerator#size and #size=" on Fri, 20 Aug 2010 10:08:44 +0900, Run Paint Run Run writes: |An enumerator is effectively immutable. The existence of #size= and |potentially invoking a Proc for each call to #size, implies that its |maximum size will change over the course of the iteration. Is this |likely? If not, we can remove #size=, and treat the Proc as a thunk, |which would be simpler and faster. We have discussed the issue in the ruby-dev before. The conclusion we had then was that: * it is nice to have a way to tell the number of items without actual iteration. * but Enumerator#size is not a good API, since not all enumerators would have the way to tell the numbers of items. Permutations and combinations are rather exceptions. * Enumerator#size= was worse, since it would make enumerators mutable. * we haven't got the better API after some discussion, so we preferred not adding it to adding unsatisfying #size. matz.