Possible duplicate:
Use Type Difference
Since there is a generic type constraint that provides equality in scala =:= , is there one that applies "not equal" to types? Mostly != But for types?
Edit
The comment below points to existing Q & A , and the answer seems to be that (1) no, it is not in the standard library (2) yes, it can be defined alone.
Therefore, I will change my question because of the thought that occurred to me after I saw the answer.
Given the existing solution:
sealed class =!=[A,B] trait LowerPriorityImplicits { implicit def equal[A]: =!=[A, A] = sys.error("should not be called") } object =!= extends LowerPriorityImplicits { implicit def nequal[A,B](implicit same: A =:= B = null): =!=[A,B] = if (same != null) sys.error("should not be called explicitly with same type") else new =!=[A,B] } case class Foo[A,B](a: A, b: B)(implicit e: A =!= B)
If A <: B or A >: B , does it really matter that A =!= B ? If not, is it possible to change the solution in such a way that if A =!= B , then this is not the case when A <: B or A >: B ?
source share