Example #1
0
 // @RubyLevelMethod(name="collect!")
 public RubyValue collect_danger(RubyBlock block) {
   RubyArray a = (RubyArray) RubyAPI.callPublicNoArgMethod(this, block, RubyID.intern("collect"));
   clear();
   for (int i = 0; i < a.size(); i++) {
     add(a.get(i));
   }
   return this;
 }
Example #2
0
 // @RubyLevelMethod(name="flatten!")
 public RubyValue flatten_danger() {
   RubyArray copy = copy();
   clear();
   boolean hasModified = recursiveAdd(this, copy);
   if (hasModified) {
     return this;
   } else {
     return RubyConstant.QNIL;
   }
 }
Example #3
0
  // @RubyLevelMethod(name="replace")
  public RubyValue replace(RubyValue arg) {
    RubyArray anotherArray = (RubyArray) arg;
    if (this == anotherArray) return this;

    clear();
    for (int i = 0; i < anotherArray.size(); i++) {
      add(anotherArray.get(i));
    }
    return this;
  }