I have a list unmentioned_colors = ["red", "green", "blue", "yellow"]
If I mention multiple colors, I want to update my unmentioned_colors array, removing the ones that I mentioned. So if I write "red green" I want to remove them from unmentioned_colors where it will become ["blue", "yellow"]
I tried
unmentioned_colors = "<? $unmentioned_colors.removeValue(@colors.values) ?>"
But it is not working.
How can I remove multiple @colors from my array?
To remove all @colors
items from $unmentioned_colors
one should set a context variable $_bool_listchanged
as shown here:
_bool_listchanged = "<? $unmentioned_colors.removeAll(@colors.values) ?>"
.
This solution does not require a loop and works because underneath the hood Watson Assistant uses Java to manipulate items in the contact. So on this array we have the method removeAll which we can call from Java.