scala - Comparing Int to Double - No Warning? -


given following case classes:

scala> case class foo(x: int) defined class foo  scala> case class bar(x: int) defined class bar 

the compiler shows warning when trying compare instances of different case classes.

scala> foo(5) == bar(5) <console>:15: warning: comparing case class values of types foo , bar using `==' yield false        foo(5) == bar(5)               ^ res8: boolean = false 

but why doesn't following comparison give warning?

scala> (5 : int) == (10 : double) res9: boolean = false 

because == overloaded method int, 1 of accepts double argument type (the same goes double, , many others). 100% legal.

abstract def ==(x: double): boolean 

see scaladocs.


Comments

Popular posts from this blog

toolbar - How to add link to user registration inside toobar in admin joomla 3 custom component -

linux - disk space limitation when creating war file -