From: Kevin Ballard Date: 2005-10-21T22:52:00+09:00 Subject: Re: Unit testing an each function Brian Schr�der wrote: > Hello Kevin, > > it is clear that reject without a block does not work, it was more a > question of visual parsing. Reject without a block has no meaning, > because we need to tell what to reject. And telling this is done with > a block. Your quite intelligent magic gives IMHO a wrong meaning to > the dot operator. You seem not to call .even? on the result of a > reject. > > Well effectively you do, but I read chained methods as doing a chain > of succeding operations on a chain of objects, and that is not what I > read when I read (1..100).reject.even? Therefore I proposed > (1..100).reject :even?, because there it is made clearer that even is > given to reject to do something. > > Nonetheless go ahed and package it as a gem. I just wanted to voice > what was disturbing me with this syntax. I understand your disturbance, but the syntax you propose makes the primary use of this idiom impossible, which is [(1..5),(10..15)].each.each { |i| puts i } What would you suggest, making [(1..5),(10..15)].each(:each) { |i| puts i } behave that way? That looks even more wrong then what my code is doing. And what if you have even further nesting? [[(1..3), (5..8)], [(4..7), (2..6)]].each.each.each { |i| puts i } Would that be [[(1..3), (5..8)], [(4..7), (2..6)]].each(:each, :each) { |i| puts i } in your syntax? That's even *harder* to read. Do you see any way to provide the proper behaviour without using the syntax my code supports?