From: Andrew McGuinness Date: 2006-01-04T05:57:57+09:00 Subject: Re: Implicit block parameter? gabriele renzi wrote: > > True, but considering how often people write > each {|x| stuff(x)} > I don't think it would be a great less in readability. > Not really advocating "it", but neither against it. No pun intended. Another way of dealing with it would be if it were easier to get from a method to a Proc object, so instead of, say heads = queues.map { |x| x.first } You could have something more like: heads = queues.map( &:first ) As with the "it" thing, you can do it for a specific method - module Enumerable def map_method( method, *args ) map { |x| x.send( method, *args ) } end end heads = queues.map_method( :first ) For things.each { |x| stuff(x) } it's possible in principle: things.each( &method(:stuff).to_proc ) But that's not exactly a simplification - I'm hoping for something more like lisp, where: (setq heads (mapcar (lambda (x) (first x)) queues)) can be replaced exactly by: (setq heads (mapcar #'first queues)) I don't know if there's a good way of doing what I want - Ruby is fundamentally unlike lisp in that objects are more fundamental than functions. I think it would be possible to allow Symbol and Method as alternatives to Proc in a "block" parameter, but I'm not sure it would be a good idea. heads = queues.map( &:first ) things.each( &method(:stuff) ) -- Andrew McGuinness http://anomalyuk.blogspot.com/