"Martin DeMello" <martindemello / yahoo.com> schrieb im Newsbeitrag
news:Y0w5a.296694$sV3.9652811 / news3.calgary.shaw.ca...
> Robert Klemme <bob.news / gmx.net> wrote:
> > I know that, sorry if I wasn't clear enough. What bugs me is the fact
that
> > the block with a single argument has negative arity, indicating that
there
> > can be more arguments. Why then doesn't the block with two arguments
have
> > arity -2, too?  Or otherwise, why doesn't the block with |a| have arity
1?
>
> Tangentially, is the following code safe:
>
>  def initialize(*factors)
>    @factors = factors
>    @filters = []
>    @factors.select {|i| i.is_a?(Proc)}.each {|fn|
>      (@filters[(fn.arity.abs) -1] ||= []) << fn
>      # ( a kludge to get around the fact that {|x|}.arity = -1 )
>    }
>    @factors.reject!{|i| i.is_a?(Proc)}
>    @dim = @factors.length
>  end
>
> assuming the blocks in @factors are guaranteed not to have *d arguments?
> Or is there some insidious corner case I'm missing?

I'm not sure whether I understand where you're up to.  I wonder why you
substract 1 from the abs(arity).

And another tip aside: move the reject! above then @factors.select. Then
you can omit the select and gain a bit performance. :-)

    robert