On 11/29/06, Giles Bowkett <gilesb / gmail.com> wrote:
> I've got something which basically does this:
>
> some_string.scan(/(whatever)/).each &do_stuff
>
> where &do_stuff is a Proc.
>
> currently there's a case/when that assigns different Procs to do_stuff
> depending on the value of some_string.
>
> what I want to do is something like this:
>
> some_string.scan(/(whatever)/).each do_stuff
>
> where do_stuff() is a method which figures out what Proc to return to
> the each().
>
> however, I can't seem to build a method which returns a Proc.
>
> can it be done?
>
sure

def do_stuff
  lambda {|a| a+1}
end

b = [1,2].map(&do_stuff)

/Robert Feldt