Reputation: 149
How can I get only the items ahead of a specified index in a list? Example:
var numbers = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]; print(numbers[3..]);
Output: 4, 5, 6, 7, 8, 9, 10
Upvotes: 0
Views: 431
Reputation: 6544
You can use the skip method, to skip a number of elements at the start of a List, for example:
var numbers = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]; print(numbers.skip(3)); //Returns an iterable: (4, 5, 6, 7, 8, 9, 10)
Upvotes: 2