public static <T> List<T> getAt(ListWithDefault<T> self, Range range) {
        RangeInfo info = subListBorders(self.size(), range);

        // if a positive index is accessed not initialized so far
        // initialization up to that index takes place
        if (self.size() < info.to) {
            self.get(info.to - 1);
        }

        List<T> answer = self.subList(info.from, info.to);
        if (info.reverse) {
            answer =  ListWithDefault.newInstance(reverse(answer), self.isLazyDefaultValues(), self.getInitClosure());
        } else {
            // instead of using the SubList backed by the parent list, a new ArrayList instance is used
            answer =  ListWithDefault.newInstance(new ArrayList<T>(answer), self.isLazyDefaultValues(), self.getInitClosure());
        }

        return answer;
    }
public static < T > List < T > getAt ( ListWithDefault < T > self , Range range ) { RangeInfo info = subListBorders ( self . size ( ) , range ) ; if ( self . size ( ) < info . to ) { self . get ( info . to - 1 ) ; } List < T > answer = self . subList ( info . from , info . to ) ; if ( info . reverse ) { answer = ListWithDefault . newInstance ( reverse ( answer ) , self . isLazyDefaultValues ( ) , self . getInitClosure ( ) ) ; } else { answer = ListWithDefault . newInstance ( new ArrayList < T > ( answer ) , self . isLazyDefaultValues ( ) , self . getInitClosure ( ) ) ; } return answer ; }
Support the range subscript operator for an eager or lazy List.
<pre class="groovyTestCase">def list = [].withDefault { 42 }
assert list[1..2] == [null, 42]</pre>

@param self  a ListWithDefault
@param range a Range indicating the items to get

@return a new eager or lazy list instance based on range borders