Kotlin / kotlin-koans

Kotlin workshop
MIT License
2.6k stars 1.41k forks source link

Spurious line in Koan 25 Comparisons? #88

Closed efung closed 7 years ago

efung commented 7 years ago

Why is this line present, from test/iii_conventions/_25_Comparison.kt:

    operator fun MyDate.compareTo(other: MyDate): Int = todoTask25()

I think its presence allows the test code to compile, but if you add the operator extension function to MyDate.kt, this line in the test file is still used so the test is still broken. By commenting it out, the test passed for me.

svtk commented 7 years ago

You're right, this line makes the tests compile. The task contains "Make the class 'MyDate' implement 'Comparable'" which implies that you won't create an extension. If you create an extension, you can remove the extension in tests.