List::slice
Return a new list consisting of the items from index i (inclusive)
to index j (exclusive). If j
is negative, count backwards from
the end.
[10, 11, 12].slice(0, 2) //-> [10, 11]
[10, 11, 12].slice(1, -1) //-> [11]
Source Codepublic method slice<T>(this: List<T>, i: Int, j: Int): List<T> {
if (j < 0) {
j = this.len() + j
}
let items: List<T> = []
let index = 0
for item in this {
if (index >= i) && (index < j) {
items = items.append(item)
}
index += 1
}
items
}