def parse_index(*args)
      # what we must do:
      #
      #   -- move numbers into range 0..length-1
      #   -- i..j   -->  i...j+1
      #   -- i...j  -->  i, j-i
      case args.length
      when 1
        arg = args.first
        if arg.is_a? ::Range
          if arg.exclude_end?
            i = wrap_index(arg.begin)
            j = wrap_index(arg.begin)
            return [i, j-1, true]
          else
            i = wrap_index(arg.begin)
            j = wrap_index(arg.begin)
            return [i, j+1-i, true]
          end
        else
          i = wrap_index(arg)
          return [i, 1, false]
        end
      when 2
        return [args[0], args[1], true]
      else
        raise ArgumentError, "wrong number of arguments"
      end
    end
def parse_index(*args)
      # what we must do:
      #
      #   -- move numbers into range 0..length-1
      #   -- i..j   -->  i...j+1
      #   -- i...j  -->  i, j-i
      case args.length
      when 1
        arg = args.first
        if arg.is_a? ::Range
          if arg.exclude_end?
            i = wrap_index(arg.begin)
            j = wrap_index(arg.begin)
            return [i, j-1, true]
          else
            i = wrap_index(arg.begin)
            j = wrap_index(arg.begin)
            return [i, j+1-i, true]
          end
        else
          i = wrap_index(arg)
          return [i, 1, false]
        end
      when 2
        return [args[0], args[1], true]
      else
        raise ArgumentError, "wrong number of arguments"
      end
    end
-----------------------------------------------------

 Return `[i, n, splat?]', where if `args' is used as an index to
 ::Array#[]=, it is equivalent to calling:

   val = args.pop
   if splat?
     array[i, n] = *val
   else
     array[i, n] = val
   end