| 1 |
class Date(y: Int, m: Int, d: Int) extends Ord: |
| 2 |
// previous decls here |
| 3 |
|
| 4 |
def <(that: Any): Boolean = that match |
| 5 |
case d: Date => |
| 6 |
(year < d.year) || |
| 7 |
(year == d.year && (month < d.month || |
| 8 |
(month == d.month && day < d.day))) |
| 9 |
|
| 10 |
case _ => sys.error("cannot compare " + that + " and a Date") |
| 11 |
end < |
| 12 |
end Date |
| 13 |
|
| 14 |
// From https://docs.scala-lang.org/tutorials/scala-for-java-programmers.html |
| 15 |
|