I have a simple problem that I’m having trouble thinking around:
var oldValues : Array = [ 4, 5, 6 ];
var newValues : Array = [ 3, 4, 6, 7 ];
- I want to get the values from newValues that aren’t in oldValues – 3, 7
- I want to get the values from oldValues that aren’t in newValues – 5
- A way of getting both sets of values together would be nice as well – 3, 5, 7
I can only think of convoluted methods for each by using nested loops that do a lot of redundant checking. Can someone suggest something more clean? Thanks.
You need a bunch of loops, but you can optimize them and totally avoid nested loops by using a lookup object.
Results: