From: Gavin Sinclair Date: 2003-10-05T09:35:52+09:00 Subject: Re: [ANN] Ruby/Extensions 0.2.0 On Sunday, October 5, 2003, 2:41:25 AM, Florian wrote: > Gavin Sinclair wrote: >> Hi -talk, > Moin! >> I have released Ruby (Standard Class) Extensions version 0.2.0. > Could you include this in the next release? :) > class Symbol > def to_proc > proc { |obj, *args| obj.send(self, *args) } > end > end > It allows you do the following: > (1..10).inject(&:*) # => 3628800 > %w{foo bar qux}.map(&:reverse) # => %w{oof rab xuq} > [1, 2, nil, 3, nil].reject(&:nil?) # => [1, 2, 3] > %w{ruby and world}.sort_by(&:reverse) # => %w{world and ruby} That's quite nice. Are there any nasty side-effects? I suppose not, since you must inform Ruby that you intend to use a symbol in place of a proc with the '&'. I'll chuck it in now, but it won't see a release for a while. Thanks, Gavin