Skip to content

format

typescript
HashSet.forEach(callback)

class: HashSet

description

Iterates through a collection.

parameter

param_nametypedescription
callbackCallbackThe callback function.

reture

typedescription
void

code example

typescript
let myHashSet = new HashSet<String>(String);
// Add elements to myHashSet
myHashSet.Add("apple");
myHashSet.Add("banana");
myHashSet.Add("orange");

let otherHashSetObj = new HashSet<String>(String);
let callback = (item: String): void => {
    otherHashSetObj.Add(item);
}
// Iterate through the collection and add elements from myHashSet to otherHashSetObj
myHashSet.forEach(callback);