prc.arity â fixnum
Instance Public methods
Returns the number of arguments that would not be ignored. If the block is
declared to take no arguments, returns 0. If the block is known to take
exactly n arguments, returns n. If the block has optional arguments, return
-n-1, where n is the number of mandatory arguments. A proc
with no argument declarations is the same a block declaring ||
as its arguments.
proc {}.arity #=> 0 proc {||}.arity #=> 0 proc {|a|}.arity #=> 1 proc {|a,b|}.arity #=> 2 proc {|a,b,c|}.arity #=> 3 proc {|*a|}.arity #=> -1 proc {|a,*b|}.arity #=> -2 proc {|a,*b, c|}.arity #=> -3 proc { |x = 0| }.arity #=> 0 lambda { |a = 0| }.arity #=> -1 proc { |x=0, y| }.arity #=> 0 lambda { |x=0, y| }.arity #=> -2 proc { |x=0, y=0| }.arity #=> 0 lambda { |x=0, y=0| }.arity #=> -1 proc { |x, y=0| }.arity #=> 1 lambda { |x, y=0| }.arity #=> -2 proc { |(x, y), z=0| }.arity #=> 1 lambda { |(x, y), z=0| }.arity #=> -2
Please login to continue.