Whatever message this page gives is out now! Go check it out!
setRetainAll(targetSet, sourceSet)| Parameter | Description |
|---|---|
| targetSet | Set to mutate. |
| sourceSet | Elements to keep. |
cfscript (syntax: setRetainAll(targetSet, sourceSet)).
<cfscript>
a = setNew();
a.add(1);
a.add(2);
a.add(3);
b = setNew();
b.add(2);
b.add(3);
b.add(4);
setRetainAll(a, b);
writeOutput(a.size()); // 2 (only 2 and 3)
</cfscript>
<cfscript>
allowed = setNew();
allowed.add("SKU-A");
allowed.add("SKU-B");
allowed.add("SKU-C");
cart = setNew();
cart.add("SKU-A");
cart.add("SKU-Z"); // not allowed
setRetainAll(cart, allowed);
writeOutput(cart.has("SKU-Z")); // false
writeOutput(cart.has("SKU-A")); // true
</cfscript>