I am creating some parameterized C [T] classes, and I want some characteristics requirements of type T to be a parameter of my class. It would be simple if I just wanted to say that T is inherited from traits or classes (as happens with Ordering). But I want him to implement some functions.
For example, I saw that many predefined types implement MinValue and MaxValue, I would like my type T to implement them too. I got some tips to just define an implicit function. But I would not want all users to be obligated to implement this function for them when it is already implemented. I could implement them in my code too, but it seemed like a very bad decision.
For example, when defining heaps, I would like to allow users to create an empty heap. In these cases, I want to put in place a value with a minimum value that can be of type T. Obviously, this code does not work.
class Heap[T](val value:T,val heaps:List[Heap[T]]){
def this()=this(T.MinValue,List())
}
I would also like to get some tips on the really good online links of Scala 2.8.
Bruna source
share