Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 354401 - Xtend2 - add a union function
Summary: Xtend2 - add a union function
Status: CLOSED FIXED
Alias: None
Product: TMF
Classification: Modeling
Component: Xtext (show other bugs)
Version: unspecified   Edit
Hardware: PC Mac OS X - Carbon (unsup.)
: P3 enhancement (vote)
Target Milestone: ---   Edit
Assignee: Project Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-08-10 11:45 EDT by Bernd Kolb CLA
Modified: 2017-09-19 18:05 EDT (History)
3 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
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