Just learning to define a DateRange type
val wholeYear2017 = Date(2017,1,1)..Date(2017,12,31)
So I created the type as below
class DateRange<Date: Comparable<Date>>(override val start: Date, override val endInclusive: Date)
: ClosedRange<Date>
class Date (val year: Int, val month: Int, val day: Int) {
operator fun compareTo(other: Date): Int {
if (this.year > other.year) return 1
if (this.year < other.year) return -1
if (this.month > other.month) return 1
if (this.month < other.month) return -1
if (this.day > other.day) return 1
if (this.day < other.day) return -1
return 0
}
operator fun rangeTo(that: Date): DateRange = DateRange(this, that)
}
But I got a compile error
One type of argument expected for class DateRange<Date: Comparable<Date>> : ClosedRange<Date>
What did I missed? Did I do it correctly?