Ejemplo n.º 1
0
  private String replace(String source, int start, int end, String replacement) {
    AssertMe.rho_assert(start <= source.length() /* - 1*/);

    if (end < start) {
      end = start + 1;
    }

    StringBuffer result = new StringBuffer(source.substring(0, start));
    result.append(replacement);
    result.append(source.substring(end));
    return result.toString();
  }
Ejemplo n.º 2
0
  // create a new Array containing every element from index to the end
  public RubyValue collect(int index) {
    AssertMe.rho_assert(index >= 0);

    final int size = array_.size() - index;
    if (size < 0) {
      return new RubyArray();
    }

    RubyArray a = new RubyArray(size);
    for (int i = index; i < array_.size(); ++i) {
      a.add(array_.get(i));
    }

    return a;
  }