From: Michal Suchanek Date: 2009-02-13T05:00:10+09:00 Subject: [ruby-core:22043] Re: 1.8.7 Specifics On 12/02/2009, Akinori MUSHA wrote: > On Thu, Feb 12, 2009 at 9:59 PM, Michal Suchanek wrote: > > 2009/2/12 Akinori MUSHA : > >> On Thu, Feb 12, 2009 at 9:24 AM, Michal Suchanek wrote: > >>> Some methods in 1.8.7 return Enumerator instead of an Array. This adds > >> > >> Would you please name an example? > >> > >> I think I was careful enough not to change the existing behavior > >> unless it was pretty certain that no one would rely on it. (e.g. > >> return value was undefined/undetermined/undocumented, omitting a block > >> simply causes exception, etc.) > > > > To give an example of code which is broken by Enumerator: > > > > File.open("2.6.28-rc6-rc7.patch"){|f|f.lines[1..3]} > > NoMethodError: undefined method `[]' for # > > from (irb):1 > > from (irb):1:in `open' > > from (irb):1 > > from :0 > > > Ruby 1.8.6 did not have {IO,File}#lines. It first appeared in 1.8.7 > as part of backport from 1.9. > You must be confusing with something else. Yes, there is no IO#lines in 1.8.6. As documented by ri there is no use of Enumerator that would break anything. And in my code I see no instance of to_a so I have likely dropped that part. I recall I had a problem with a script that failed because of a method missing on Enumerator when Debian upgraded to 1.8.7 but I have not reported it as a bug because nobody seemed to care at the time and the workaround was easy enough. Maybe the code was broken to start with. Until I find what it was I cannot be sure. Thanks Michal