In a recent Kotlin project I wrote an interface definition meant to be consumable from Java and possibly other Kotlin code. It contains only one method, so I expected it to be usable in Kotlin code as a Single Abstract Method implementation literal, e.g.
SomeInterface { arg -> ... }. This didn't compile, noting that the interface type has no constructors. Apparently interfaces
defined in Kotlin cannot be used in this fashion, possibly as an encouragement to just
pass functions instead.
No comments:
Post a Comment