| Summary: | Xtend2 - add a union function | ||
|---|---|---|---|
| Product: | [Modeling] TMF | Reporter: | Bernd Kolb <b.kolb> |
| Component: | Xtext | Assignee: | 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
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. Sorry, I meant (listA + listB).toSet 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 what about
import static extension com.google.common.collect.Iterables.*
newArrayList("A","B").concat(newArrayList("C", "D"))
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 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. Closing all bugs that were set to RESOLVED before Neon.0 Closing all bugs that were set to RESOLVED before Neon.0 |