I have a Record set up like this:
let myRecord = Record<String, Set<String>>
How can I add an element to a set inside the record? I have tried the following without success:
let key = "key";
let stringToAdd = "stringToAdd";
myRecord[key].add(stringToAdd);
You can use the square brackets []
and an assignment to add elements to the record.
let mySet: Set<string> = new Set();
mySet.add("stringToAdd");
let myRecord: Record<string, Set<string>> = {};
myRecord["key"] = mySet; // <--- Like this
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With