On 11/29/06, Giles Bowkett <gilesb / gmail.com> wrote:

> however, I can't seem to build a method which returns a Proc.
>
> can it be done?

Yes, but you still need to prefix it with a & when passing it to a
method that expects a block.

irb(main):001:0> def foo
irb(main):002:1> lambda {|x| x+1}
irb(main):003:1> end
=> nil
irb(main):004:0> (1..10).map foo
ArgumentError: wrong number of arguments (1 for 0)
        from (irb):4:in `map'
        from (irb):4
irb(main):005:0> (1..10).map &foo
=> [2, 3, 4, 5, 6, 7, 8, 9, 10, 11]


martin