From: Christoph Date: 2004-11-06T20:41:45+09:00 Subject: Re: require 'enumerator' Yukihiro Matsumoto schrieb: >Here's the explanation: > >enum_cons() gathers values generated by each_cons(). each_cons() >passes same array modifying for each time. Thus all elements in the >to_a array refers to the same array, thus it seems that all elements >are [9,10]. > >I'm not sure yet how it should behave. Perhaps it should copy >returning arrays somewhere. > > Actually I would be surprised by anything but the current efficient behavior, and very much prefer not change this to coping behavior. If need for the latter arises I can always do it myself. e.g. (1..10).enum_cons(2).collect{|x| x.clone } /Christoph