
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.Iterator;
import java.util.List;
import java.util.ListIterator;

public class RArray extends RObject {
    public final ArrayList<RObject> impl;
    
    public RArray() {
        impl = new ArrayList<RObject>();
    }
    
    public RArray(RObject... args) {
        impl = new ArrayList<RObject>(Arrays.asList(args));
    }
    
    public RArray(List<RObject> impl) {
        this.impl = new ArrayList<RObject>(impl);
    }
    
    public RObject $less$less(RObject what) {
        add(what);
        
        return this;
    }
    
    public RObject $lbrack$rbrack(RObject where) {
        int index = (int)((RFixnum)where.to_i()).fix;
        
        if (index < size()) {
            return get(index);
        }
        
        return RNil;
    }
    
    public RObject $lbrack$rbrack$equal(RObject where, RObject what) {
        int index = (int)((RFixnum)where.to_i()).fix;
        
        // TODO index >= size
        impl.set(index, what);
        
        return this;
    }

    public RObject size() {
        return new RFixnum(impl.size());
    }

    public RObject clear() {
        impl.clear();
        return this;
    }
}

@@ -580,16 +580,21 @@
         
+impl.
 add(what
@@ -771,16 +771,98 @@
 index %3C 
+0) %7B%0A            index = impl.size() + index;%0A        %7D%0A%0A        if (index %3C impl.
 size()) 
@@ -882,16 +882,21 @@
  return 
+impl.
 get(inde
@@ -908,26 +908,28 @@
        %7D
-%0A    
+ else %7B%0A
     
-%0A
         
@@ -941,16 +941,26 @@
 n RNil;%0A
+        %7D%0A
     %7D%0A  
@@ -1108,29 +1108,167 @@
     
-// TODO index %3E= size
+if (index %3C 0) %7B%0A            index = impl.size() + index;%0A        %7D%0A%0A        if (index %3E= impl.size()) %7B%0A            impl.ensureCapacity(index + 1);%0A        %7D%0A
 %0A   

Fix existing Array methods and support negative and >= size sets.