私は、次の醜いパターンを何度も書いていることに気づきました。
class Something[A, B](implicit ev: A =:= B = null) {
...
def doStuff {
if (ev == null) ... // know that A is not the same as B
else ... // safely assume A is equal to B
}
}
さらに悪いことに、 のときev != null
は、 などの異端を書くこともありましたsomeB.asInstanceOf[A]
。