The skipWhile()
method accepts a boolean test function as a parameter. Every element in the hash set is passed through the boolean test function. The elements that pass the test function (the function returns true) are skipped. In contrast, the elements that fail the test function are retained (the function returns false).
The iteration over the elements of the set is stopped once an element for which the test function fails. The remaining elements in the set are returned as is.
hashset.skipWhile(test_function)
test_function
: A boolean function.skipWhile
: Skips an element until it passes the function.The method returns an iterable value.
import 'dart:collection';void main() {var educativeSet = HashSet<String>();educativeSet.add("courses");educativeSet.add("answers");educativeSet.add("educative");educativeSet.add("assessments");educativeSet.add("projects");print('1.\tThe elements of the set are:\n\t $educativeSet');var iterator = educativeSet.skipWhile((element) => element.length > 7);print('2.\tAfter skipping the elements with length greater than 7: \n\t $iterator');}
HashSet
class of type String is created.add()
method, elements are added to the hash set.7
are skipped using the skipWhile()
method.Free Resources