Scala equality with type checking?
问题 Is there a uniform method to perform equality with type checking? Unfortunately val objectA:String = "test" val objectB:Int = 2 objectA == objectB the equality operator == doesn't complain if objectB is a Int while objectA is a String. I would need an operator like === that perform type checking as well (and I hope it is uniform to all scala obj). Does such operator exist? 回答1: You need to look at scalaz's === for type-safe equals - it's implemented as type class there. You can also watch