defined addition for maps prioritizing set operations.

This commit is contained in:
gnembon committed 2020-07-08 00:48:29 -03:00
1 parent 307ce57c0b
commit 72ffc5b8b9
3 files changed
+38 -6

No files matched your search

@@ -97,8 +97,24 @@ public class MapValue extends AbstractListValue implements ContainerValueInterfa
@Override
public Value add(Value o)
{
append(o);
return this;
Map<Value, Value> newItems = new HashMap<>(map);
if (o instanceof MapValue)
{
newItems.putAll(((MapValue) o).map);
}
else if (o instanceof AbstractListValue)
{
Iterator<Value> it = ((AbstractListValue) o).iterator();
while (it.hasNext())
{
newItems.put(it.next(), Value.NULL);
}
}
else
{
newItems.put(o, Value.NULL);
}
return MapValue.wrap(newItems);
}
@Override