The `skip` method in Dart returns an Iterable that provides all but the first count elements.
The syntax of Runes.skip() method is:
Iterable<int> skip(int count)
This skip() method of Runes returns an Iterable that provides all but the first count
elements.
Parameter | Optional/Required | Description |
---|---|---|
count | required | The number of elements to skip from the beginning of the Iterable. |
Runes.skip() returns value of type Iterable<int>
.
In this example,
numbers
containing integers.skip()
method to skip the first 2 elements.void main() {
List<int> numbers = [1, 2, 3, 4, 5];
Iterable<int> skipped = numbers.skip(2);
print(skipped.toList());
}
[3, 4, 5]
In this example,
words
containing strings.skip()
method to skip the first element.void main() {
List<String> words = ['apple', 'banana', 'cherry'];
Iterable<String> skipped = words.skip(1);
print(skipped.toList());
}
[banana, cherry]
In this example,
uniqueNumbers
containing integers.skip()
method to skip the first element.void main() {
Set<int> uniqueNumbers = {1, 2, 3};
Iterable<int> skipped = uniqueNumbers.skip(1);
print(skipped.toList());
}
[2, 3]
In this Dart tutorial, we learned about skip() method of Runes: the syntax and few working examples with output and detailed explanation for each example.