According to the official documentation,
"SAM conversions only work for interfaces, not for abstract classes, even if those also have just a single abstract method."
But I just tried it with an Abstract Class and it seems to work.
Did I not understand the documentation properly or this is now possible in New Kotlin version? 🤔
https://kotlinlang.org/docs/reference/java-interop.html#sam-conversions
n
Nicholas Bilyk
11/11/2020, 2:13 PM
Hmm. Was your abstract class from Java or Kotlin? I think they meant that SAM conversions only work for kotlin interfaces (marked fun interface), but I think any single method class in Java can be used with SAM conversions.
n
Nuru
11/11/2020, 2:14 PM
It was in Kotlin, I tried it in the Kotlin Playground.
n
Nicholas Bilyk
11/11/2020, 2:25 PM
Link? I'm curious
n
Nuru
11/11/2020, 3:39 PM
I could have sworn that it worked the first time but maybe I probably got things mixed up.
Because I just re-wrote it and it doesn't seem to work 😐🙁
https://pl.kotl.in/ESom5wOfd