From: Dave Burt Date: 2005-10-28T23:47:04+09:00 Subject: Re: Cleaner syntax for .map (is there already a way, or ruby2 idea?) David A. Black wrote: > I continue to struggle to understand what people find so horrible > about ary.each {|item| .... }, ary.map {|item| ... }, and so forth. > I'll have some more coffee and maybe I'll start to see the light.... There's nothing really wrong with them, but they are verbose in simple (and common) cases: result = array.map {|element| element.transform } The only issue is that you're saying "element" twice when you would only say it once if you were describing the operation to a person. Groovy's (optional) implicit parameter is the counterpoint: // Groovy: result = array.map { it.transform() } Tangentially, I wonder if the proposed Ruby 2 block syntax makes this slightly more possible. # Pseudo-Ruby 2.0: result = array.map -> { it.transform } Actually, probably less possible - IIRC the new block style is meant to be more like the method semantics, and so stricter on parameters. So, anyway, I don't mind the idea of an implicit parameter, but I realise it's not going to happen before Ruby 3. Cheers, Dave