Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

How to find difference of two List Option type so that elements present in List A are not in List B

Sujatha May 18, 2018

Hello,

I am writing a groovy code. My Code has two List of type Option value fetched from custom field(NewRes and OldRes).

def ListA = issue.getCustomFieldValue(newRes) as List<Option>
def ListB= issue.getCustomFieldValue(oldRes) as List<Option> 

Assume that Option List A  and List B has following set of values:

List A :  { os, op, jp, zp} and

List B : {op,zp}

How to find elements such that they are in List A but not in List B.

I need a third List option(List C) with elements in A but Not in B i.e List C must contains { os, jp}

 

Please reply. Thanks !

 

2 answers

2 accepted

1 vote
Answer accepted
Rambabu Patina _Appfire_
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
May 18, 2018
You can try use:
def newlist = ListA.minus(ListB);
Rambabu Patina _Appfire_
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
May 18, 2018
Sujatha May 19, 2018

Thanks Ram for the solution and link 

1 vote
Answer accepted
Alexey Matveev
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
May 18, 2018

Hello,

def ListC = ListA - ListB

Sujatha May 19, 2018

Thanks Alexey. It works!

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events