On 24.02.2008 14:55, Arlen C. wrote:
(ooh, buzzword) Symbol by adding Symbol#to_proc to do some method
resolution. Not sure how well it’ll work for you, but a guess.
Not necessary. Here’s another approach that has the added advantage
that it will also work with 1.8 - and it’s short and conscise:
irb(main):001:0> add_one = lambda {|x| x + 1}
=> #Proc:0x7ff9c4bc@:1(irb)
irb(main):002:0> (1…3).map &add_one
=> [2, 3, 4]
irb(main):003:0>
Although I have to say it’s not clear to me what speaks against doing
(1…3).map {|x| x + 1}.
Kind regards
robert