Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 354401

Summary: Xtend2 - add a union function
Product: [Modeling] TMF Reporter: Bernd Kolb <b.kolb>
Component: XtextAssignee: Project Inbox <tmf.xtext-inbox>
Status: CLOSED FIXED QA Contact:
Severity: enhancement    
Priority: P3 CC: christian.dietrich.opensource, sebastian.zarnekow, sven.efftinge
Version: unspecified   
Target Milestone: ---   
Hardware: PC   
OS: Mac OS X - Carbon (unsup.)   
Whiteboard:

Description Bernd Kolb CLA 2011-08-10 11:45:21 EDT
Build Identifier: 

Please add a union function which creates a collection list out of two given collections

Reproducible: Always
Comment 1 Sebastian Zarnekow CLA 2011-08-10 11:58:35 EDT
Why doesn't listA + listB work for you? If you want a union, you could even do a newLinkedHashSet(listA + listB). Please reopen if I missed your point.
Comment 2 Sebastian Zarnekow CLA 2011-08-10 11:59:36 EDT
Sorry, I meant (listA + listB).toSet
Comment 3 Bernd Kolb CLA 2011-08-10 12:15:02 EDT
That works. But if you are somewhere in an expression it feels more natural (to me) to write
a.b.c.union(x.y.z).doSomething 

than

(a.b.c + x.y.z).doSomething

Please close again if you don't agree
Comment 4 Christian Dietrich CLA 2011-08-11 14:54:27 EDT
what about

import static extension com.google.common.collect.Iterables.*

newArrayList("A","B").concat(newArrayList("C", "D"))
Comment 5 Sebastian Zarnekow CLA 2011-08-11 15:02:55 EDT
I don't like the idea to have something like union on iterables or collections. Union (and intersection) are set operations and are indeed available on com.google.common.collect.Sets.

I can imagine to have #concat as an alias to iterable+iterable and #union, #intersection and #difference available on instances of java.util.Set
Comment 6 Sven Efftinge CLA 2011-11-21 06:47:31 EST
Closing this since the standard lib supports (listA + listB).toSet and if that is not good enough in a certain context one can define an extension method for that context.
Comment 7 Karsten Thoms CLA 2017-09-19 17:54:47 EDT
Closing all bugs that were set to RESOLVED before Neon.0
Comment 8 Karsten Thoms CLA 2017-09-19 18:05:44 EDT
Closing all bugs that were set to RESOLVED before Neon.0