From: Trans Date: 2007-02-09T22:30:05+09:00 Subject: Re: Your favorite bit of ruby code? On Feb 9, 5:39 am, "Erik Veenstra" wrote: > In general, AFAIK, an initialize can be skipped if all it does > is a super with the same arguments. > > What am I missing? I want to learn... ;] Oh right. Yes, it can be removed in this case. I incidently left it b/ c the full version of Functor also stores the function and allows for passthru args. Ie. class Functor < Proc private *instance_methods.select { |m| m !~ /(^__|^\W|^binding $)/ } def initialize(*arguments, &function) @arguments = arguments @function = function super(&function) end def method_missing(op, *args, &blk) call(op, *(@arguments + args), &blk) end def to_a ; @arguments ; end def to_proc ; @function ; end end Passthru arguments aren't strictly neccessary in Ruby b/c of closures, but they are proper. BTW I've never been sure what to call the #to_a and #to_proc methods, those are the best reader method names I've come up with. But then again maybe full accessors would desriable. In any case they are simply extra features, and not germane to the core defintion, which is why I left them out of "my favorite bit of ruby". Make sense? T.