One necessitates the creation of an implicit object on each invocation of the call, the other merely places a type constraint on the object passed into the function. In general, I would prefer the declaration wherein you state [T <: Dummy]
rather than the implicit.
Where you'd use the implicit is when you want to create a type which can do certain things but only if it satisfies a certain constraint. Hence, you see the following in List[A]
declaration:
def sum(implicit ev: Numeric[A]) = ...
which is a nice way of saying "you can place any type 'A' in the class but if you want to use 'sum' it has to conform to..." Take for instance the following class definition:
class Foo[T](value: T){
def doubleString = value.toString() + value.toString()
def specialSauce(implicit ev: T <:< Dummy): Dummy = ...
}
This allows me the option to create some type of Foo[Int]
and it will work but won't allow me to call the specialSauce
method of the class unless T
is a direct descendent of Dummy
.