How to compare 2 lists and return a new list with the missing values using ScriptRunner

I have 2 lists eg ListA[1,2,3,4] and ListB[2,3]. I need to compare both and create a new list with the values that are not found in ListB (i.e. ListC[1,4]).

1 answer

You might try doing it like this:

def l1 = ["1", "2", "3", "4"]
def l2 = ["2", "3"]
def commons = l1.intersect(l2)
def difference = l1.plus(l2)
difference.removeAll(commons)
return difference

See image for result.

Screen Shot 2017-07-19 at 11.55.24 AM.png 

Suggest an answer

Log in or Sign up to answer
How to earn badges on the Atlassian Community

How to earn badges on the Atlassian Community

Badges are a great way to show off community activity, whether you’re a newbie or a Champion.

Learn more
Community showcase
Published Apr 30, 2018 in Marketplace Apps

Why moving to Confluence Data Center is only a job half-done

Confluence Data Center is a deployment option that was designed for performance at scale. In other words, Confluence will handle increased traffic much reliably in a clustered environment and yo...

249 views 0 6
Read article

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you