Can I make a java library that has functions that ...
# announcements
k
Can I make a java library that has functions that can be interpretted as operator overloading in Kotlin?
p
If it matches the expected signature with the right name (i.e.
public String plus(value: String)
) then you can use the operator. I think it even works with delegation. It’s fascinating that the compiler does this inference from Java but in Kotlin we need to use the operator 🙃
m
many Java libraries provide an additional module (for example: mylib-kotlin) which is written in Kotlin and contains additions over the standard Java interoperability, like extension methods, inline reified functions, operators, etc., that are useful when using the lib from Kotlin. So a Kotlin dev could import mylib and mylib-kotlin to take advantage of it. Spring does this since version 5, for example.
1
k
Cool
m
it’s easier if you organize your lib like this, instead of having a hard time dealing with critical interop points