On Feb 8, 3:49 pm, "Carl Lerche" <carl.ler... / gmail.com> wrote: > Hello, > > I'm just curious what your favorite bit of ruby code is? Do you have > any small bits, methods, classes, or anything else, that just make you > say "Wow, that is sweet!" > > I'd like to see some of them! class Functor < Proc private *instance_methods.select { |m| m !~ /(^__|^\W|^binding $)/ } def initialize(&function) super(&function) end def method_missing(op, *args, &blk) call(op, *args, &blk) end end usage example: f = Functor.new { |op, x| x.send(op, x) } f + 1 #=> 2 f + 2 #=> 4 f + 3 #=> 6 f * 1 #=> 1 f * 2 #=> 2 f * 3 #=> 9 T.