From: Kevin Ballard Date: 2005-10-20T22:46:59+09:00 Subject: Re: Unit testing an each function Brian Schr�der wrote: > > [snip] > > > > (1..100).reject.even? > > > > [snip] > > Just wanted to state that on second reading of this thread it again > did hurt in my eyes. If I read (1.100).reject I expect a resulting > array. And when I read the above I wondered shortly if even? works on > arrays maybe returning true if the array has an even number of > entries. Then I remembered the thread topic and started this text. So > a > -1 > from me for proposing this as an addition to the language. Except that (1..100).reject doesn't return an array at all unless a block is supplied - it gives a LocalJumpError. All the enumerating methods I've tested except for Enumerable#collect give an error when called without a block (#collect without a block is equivalent to #to_a). So with this change, the case where no block is supplied becomes useful as opposed to useless (and in the #collect case, I can't imagine anybody's actually relying on #collect being equivalent to #to_a when called without a block, because they should be using #to_a directly for that). In any case, I wasn't proposing this as an addition to the language (not that I would mind), I was simply proposing this as something I should package up into a gem so people could use it if they wanted.