I need to have a fixed object in scala 2.7.5, and one of its members is immutable Sort . I have no problem adding to synthesize, it gives:
class MyClass[A](s:SortedSet[A]) {
...
def + (elem:A):MyClass[A] {
new MyClass(s + elem)
}
}
And it works, since the + operator is an overload in the sortedSet to return a SortedSet.
Unfortunately, the deletion of the item is in error because - methos is not overloaded:
class MyClass[A](s:SortedSet[A]) {
...
def - (elem:A):MyClass[A] {
new MyClass(s - elem) // Compiler error: (s - elem) is a Set[A]
}
}
Does anyone know how I can get a sorted set when I suppress an element, knowing that: - I do not want to use a more specific type of set, like TreeSet. - I cannot use a less specific attribute like Set [A] instead of my SortedSet.