improved arity check code in correct_arg-arity method
This commit is contained in:
parent
92b67f2531
commit
a2ff532686
|
@ -18,7 +18,6 @@ class Pry
|
|||
if block.is_a?(Proc)
|
||||
ret = context.instance_exec(*correct_arg_arity(block.arity, args), &block)
|
||||
else
|
||||
# binding.pry
|
||||
ret = block.call(*correct_arg_arity(block.method(:call).arity, args))
|
||||
end
|
||||
|
||||
|
@ -32,12 +31,12 @@ class Pry
|
|||
|
||||
private
|
||||
def correct_arg_arity(arity, args)
|
||||
case arity <=> 0
|
||||
when -1
|
||||
case
|
||||
when arity < 0
|
||||
args
|
||||
when 0
|
||||
when arity == 0
|
||||
[]
|
||||
when 1
|
||||
when arity > 0
|
||||
# another jruby hack
|
||||
if Pry::Helpers::BaseHelpers.jruby?
|
||||
args[0..(arity - 1)]
|
||||
|
|
Loading…
Reference in New Issue