Joel VanderWerf
9/10/2007 7:38:00 PM
Dante Regis wrote:
> Hello folks,
>
> sorry for this newbie question, but I saw somewhere that there is a way to
> make a small block without using pipes " | ".
>
> It was something like [0, 1, 2].each { } , with some char inside the
> brackets, like &, but I can't remember it. anyone knows how to use it?
Maybe this?
class Symbol
def to_proc
proc {|x,*args| x.send(self, *args)}
end
end
[1,2,3].map(&:to_s) # ==> ["1", "2", "3"]
--
vjoel : Joel VanderWerf : path berkeley edu : 510 665 3407