compareTo method

  1. @override
int compareTo(
  1. YearMonth other
)
override

Implemented from Comparable which equal 0 means this and other are the same, greater than 0 means other is greater and lesser than 0 means other is lesser

It also uses the condition for operator ==, >, <, >= and <=

Implementation

@override
int compareTo(YearMonth other) =>
    ((other.year - this.year) * 12) + (other.month - this.month);