Details
-
Improvement
-
Status: Closed
-
Major
-
Resolution: Fixed
-
1.0-beta-10
-
None
Description
groovy> x = [1,1] - []
groovy> println x
groovy> go
[1]
groovy> x = [1,1] + []
groovy> println x
groovy> go
[1, 1, []]
I understand that minus doesn't mean to remove elements
but to return the difference of two collections.
It does return a set.
Plus() in contrast adds an element instead of returning
the union of elements. As a second difference, the
result is a list, not a set.
There are operations for sets like 'union' and 'difference' that have
this behaviour. And sets have no doubled entries by definition.
For lists we have 'add' and 'remove'.
The problem is that the current implementation of plus() and minus()
is a mix between the two concepts.
suggestion:
make different implementations for sets and lists.
- for sets with union/difference meaning
- for lists with add/remove meaning