def check_block_arity!(block, args)
      # Convert the block to a lambda-style proc. You can't make this shit up.
      obj = Object.new
      obj.define_singleton_method(:block, &block)
      block  = obj.method(:block).to_proc
      # Check
      required_args = block.arity < 0 ? ~block.arity : block.arity
      if args.length < required_args || (block.arity >= 0 && args.length > block.arity)
        raise ArgumentError.new("wrong number of arguments (#{args.length} for #{required_args}#{block.arity < 0 ? '+' : ''})")
      end
    end
def check_block_arity!(block, args)
      # Convert the block to a lambda-style proc. You can't make this shit up.
      obj = Object.new
      obj.define_singleton_method(:block, &block)
      block  = obj.method(:block).to_proc
      # Check
      required_args = block.arity < 0 ? ~block.arity : block.arity
      if args.length < required_args || (block.arity >= 0 && args.length > block.arity)
        raise ArgumentError.new("wrong number of arguments (#{args.length} for #{required_args}#{block.arity < 0 ? '+' : ''})")
      end
    end
Check that the given arguments match the given block. This is needed
 because Ruby will nil-pad mismatched argspecs on blocks rather than error.

 @since 2.3.0
 @param block [Proc] Block to check.
 @param args [Array<Object>] Arguments to check.
 @return [void]