Hello friends,
i'm finishing the translation of this tutorial: https://github.com/scala/scala.github.com/blob/gh-pages/tutorials/scala-for-java-programmers.md
When discussing traits, the authors define this method:
override def equals(that: Any): Boolean = that.isInstanceOf[Date] && {
val o = that.asInstanceOf[Date]
o.day == day && o.month == month && o.year == year
}
Shouldn't be better to define the same method this way:
override def equals(that: Any): Boolean = that match{
case o:Date => o.day == day && o.month == month && o.year == year
case _ => false
}
Maybe a note can be added noting the type erasure problem.
What do you think?