Closed nieldw closed 6 years ago
Hello! Please insert the solution:
class DateRange(val start: MyDate, val end: MyDate): Iterable<MyDate>{
override fun iterator(): Iterator<MyDate> = DateIterator(this)
}
class DateIterator(val dateRange:DateRange) : Iterator<MyDate> {
var current: MyDate = dateRange.start
override fun next(): MyDate {
val result = current
current = current.nextDay()
return result
}
override fun hasNext(): Boolean = current <= dateRange.end
}
fun iterateOverDateRange(firstDate: MyDate, secondDate: MyDate, handler: (MyDate) -> Unit) {
for (date in firstDate..secondDate) {
handler(date)
}
}
works fine for me :)
Thanks.
Thanks @AlexanderPrendota. It looks like there was something else going on, producing the 500s, it's working fine now.
There is an issue with this task:
https://try.kotlinlang.org/#/Kotlin%20Koans/Conventions/For%20loop/Task.kt
Trying to 'Check' the solution produces a 500, "SyntaxError: JSON.parse: unexpected end of data at line 1 column 1 of the JSON data"