3 ms·
I see the opposite. I think functional implementation of interfaces is lacking in Kotlin big time. The fact that you see a type like Comparable<T> and can impl
by DarkNova6 3y ago
I see the opposite. I think functional implementation of interfaces is lacking in Kotlin big time.
The fact that you see a type like Comparable<T> and can implement it with an anonymous function is unique to Java. In other languages you would have Function<Int, T, T> which simply baffles the mind. Java has a powerful and performant model which also benefits from static and default methods (e.g. functional composition).
Granted, the collect endpoint looks pretty wild but in 99% of cases you will simply use ".toList" or Collectors.toSet().
- eweise 3y agoI just meant that its much nicer to read and write (T) -> R vs Function<T,R> Maybe Kotlin lacks implementing interfaces functionally but in practice, I can't remember it being a pain point. Funtional programming in Java to me, still feels very clunky compared to scala and kotlin.