Recently looking at Kotlin and you can do .. or to on some custom classes instead of Int or others.
Kotlin achieves that through an extension function as follow:
operator fun <T: Comparable<T>> T.rangeTo(that: T): ClosedRange<T>
which means as long as your class implements Comparable interface you can get that for free so you can do:
val now = LocalDate.now()
val vacation = now..now.plusDays(10)
I found that's quite convenient. Just wondering how can we do it in Scala, I know somehow we should achieve it through type class? Maybe right or wrong.
Can anyone showed me the simplest way to do it in Scala? Looks like there is no built in at least for LocalDate